@@ -63,12 +63,12 @@ class Project
6363 # @param notification_center - Optional Instance of NotificationCenter.
6464 # @param event_processor - Optional Responds to process.
6565
66- def initialize (
66+ def initialize ( # rubocop:disable Metrics/ParameterLists
6767 datafile = nil ,
6868 event_dispatcher = nil ,
6969 logger = nil ,
7070 error_handler = nil ,
71- skip_json_validation = false ,
71+ skip_json_validation = false , # rubocop:disable Style/OptionalBooleanParameter
7272 user_profile_service = nil ,
7373 sdk_key = nil ,
7474 config_manager = nil ,
@@ -146,8 +146,7 @@ def create_user_context(user_id, attributes = nil)
146146 # validate attributes
147147 return nil unless user_inputs_valid? ( attributes )
148148
149- user_context = OptimizelyUserContext . new ( self , user_id , attributes )
150- user_context
149+ OptimizelyUserContext . new ( self , user_id , attributes )
151150 end
152151
153152 def decide ( user_context , key , decide_options = [ ] )
@@ -219,11 +218,9 @@ def decide(user_context, key, decide_options = [])
219218 decision_source = decision . source
220219 end
221220
222- unless decide_options . include? OptimizelyDecideOption ::DISABLE_DECISION_EVENT
223- if decision_source == Optimizely ::DecisionService ::DECISION_SOURCES [ 'FEATURE_TEST' ] || config . send_flag_decisions
224- send_impression ( config , experiment , variation_key || '' , flag_key , rule_key || '' , feature_enabled , decision_source , user_id , attributes )
225- decision_event_dispatched = true
226- end
221+ if !decide_options . include? ( OptimizelyDecideOption ::DISABLE_DECISION_EVENT ) && ( decision_source == Optimizely ::DecisionService ::DECISION_SOURCES [ 'FEATURE_TEST' ] || config . send_flag_decisions )
222+ send_impression ( config , experiment , variation_key || '' , flag_key , rule_key || '' , feature_enabled , decision_source , user_id , attributes )
223+ decision_event_dispatched = true
227224 end
228225
229226 # Generate all variables map if decide options doesn't include excludeVariables
@@ -610,15 +607,13 @@ def get_feature_variable(feature_flag_key, variable_key, user_id, attributes = n
610607 @logger . log ( Logger ::ERROR , InvalidProjectConfigError . new ( 'get_feature_variable' ) . message )
611608 return nil
612609 end
613- variable_value = get_feature_variable_for_type (
610+ get_feature_variable_for_type (
614611 feature_flag_key ,
615612 variable_key ,
616613 nil ,
617614 user_id ,
618615 attributes
619616 )
620-
621- variable_value
622617 end
623618
624619 # Get the String value of the specified variable in the feature flag.
@@ -636,15 +631,13 @@ def get_feature_variable_string(feature_flag_key, variable_key, user_id, attribu
636631 @logger . log ( Logger ::ERROR , InvalidProjectConfigError . new ( 'get_feature_variable_string' ) . message )
637632 return nil
638633 end
639- variable_value = get_feature_variable_for_type (
634+ get_feature_variable_for_type (
640635 feature_flag_key ,
641636 variable_key ,
642637 Optimizely ::Helpers ::Constants ::VARIABLE_TYPES [ 'STRING' ] ,
643638 user_id ,
644639 attributes
645640 )
646-
647- variable_value
648641 end
649642
650643 # Get the Json value of the specified variable in the feature flag in a Dict.
@@ -662,15 +655,13 @@ def get_feature_variable_json(feature_flag_key, variable_key, user_id, attribute
662655 @logger . log ( Logger ::ERROR , InvalidProjectConfigError . new ( 'get_feature_variable_json' ) . message )
663656 return nil
664657 end
665- variable_value = get_feature_variable_for_type (
658+ get_feature_variable_for_type (
666659 feature_flag_key ,
667660 variable_key ,
668661 Optimizely ::Helpers ::Constants ::VARIABLE_TYPES [ 'JSON' ] ,
669662 user_id ,
670663 attributes
671664 )
672-
673- variable_value
674665 end
675666
676667 # Get the Boolean value of the specified variable in the feature flag.
@@ -689,15 +680,13 @@ def get_feature_variable_boolean(feature_flag_key, variable_key, user_id, attrib
689680 return nil
690681 end
691682
692- variable_value = get_feature_variable_for_type (
683+ get_feature_variable_for_type (
693684 feature_flag_key ,
694685 variable_key ,
695686 Optimizely ::Helpers ::Constants ::VARIABLE_TYPES [ 'BOOLEAN' ] ,
696687 user_id ,
697688 attributes
698689 )
699-
700- variable_value
701690 end
702691
703692 # Get the Double value of the specified variable in the feature flag.
@@ -716,15 +705,13 @@ def get_feature_variable_double(feature_flag_key, variable_key, user_id, attribu
716705 return nil
717706 end
718707
719- variable_value = get_feature_variable_for_type (
708+ get_feature_variable_for_type (
720709 feature_flag_key ,
721710 variable_key ,
722711 Optimizely ::Helpers ::Constants ::VARIABLE_TYPES [ 'DOUBLE' ] ,
723712 user_id ,
724713 attributes
725714 )
726-
727- variable_value
728715 end
729716
730717 # Get values of all the variables in the feature flag and returns them in a Dict
@@ -809,15 +796,13 @@ def get_feature_variable_integer(feature_flag_key, variable_key, user_id, attrib
809796 return nil
810797 end
811798
812- variable_value = get_feature_variable_for_type (
799+ get_feature_variable_for_type (
813800 feature_flag_key ,
814801 variable_key ,
815802 Optimizely ::Helpers ::Constants ::VARIABLE_TYPES [ 'INTEGER' ] ,
816803 user_id ,
817804 attributes
818805 )
819-
820- variable_value
821806 end
822807
823808 def is_valid
0 commit comments