@@ -63,12 +63,12 @@ class Project
63
63
# @param notification_center - Optional Instance of NotificationCenter.
64
64
# @param event_processor - Optional Responds to process.
65
65
66
- def initialize (
66
+ def initialize ( # rubocop:disable Metrics/ParameterLists
67
67
datafile = nil ,
68
68
event_dispatcher = nil ,
69
69
logger = nil ,
70
70
error_handler = nil ,
71
- skip_json_validation = false ,
71
+ skip_json_validation = false , # rubocop:disable Style/OptionalBooleanParameter
72
72
user_profile_service = nil ,
73
73
sdk_key = nil ,
74
74
config_manager = nil ,
@@ -146,8 +146,7 @@ def create_user_context(user_id, attributes = nil)
146
146
# validate attributes
147
147
return nil unless user_inputs_valid? ( attributes )
148
148
149
- user_context = OptimizelyUserContext . new ( self , user_id , attributes )
150
- user_context
149
+ OptimizelyUserContext . new ( self , user_id , attributes )
151
150
end
152
151
153
152
def decide ( user_context , key , decide_options = [ ] )
@@ -219,11 +218,9 @@ def decide(user_context, key, decide_options = [])
219
218
decision_source = decision . source
220
219
end
221
220
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
227
224
end
228
225
229
226
# 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
610
607
@logger . log ( Logger ::ERROR , InvalidProjectConfigError . new ( 'get_feature_variable' ) . message )
611
608
return nil
612
609
end
613
- variable_value = get_feature_variable_for_type (
610
+ get_feature_variable_for_type (
614
611
feature_flag_key ,
615
612
variable_key ,
616
613
nil ,
617
614
user_id ,
618
615
attributes
619
616
)
620
-
621
- variable_value
622
617
end
623
618
624
619
# 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
636
631
@logger . log ( Logger ::ERROR , InvalidProjectConfigError . new ( 'get_feature_variable_string' ) . message )
637
632
return nil
638
633
end
639
- variable_value = get_feature_variable_for_type (
634
+ get_feature_variable_for_type (
640
635
feature_flag_key ,
641
636
variable_key ,
642
637
Optimizely ::Helpers ::Constants ::VARIABLE_TYPES [ 'STRING' ] ,
643
638
user_id ,
644
639
attributes
645
640
)
646
-
647
- variable_value
648
641
end
649
642
650
643
# 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
662
655
@logger . log ( Logger ::ERROR , InvalidProjectConfigError . new ( 'get_feature_variable_json' ) . message )
663
656
return nil
664
657
end
665
- variable_value = get_feature_variable_for_type (
658
+ get_feature_variable_for_type (
666
659
feature_flag_key ,
667
660
variable_key ,
668
661
Optimizely ::Helpers ::Constants ::VARIABLE_TYPES [ 'JSON' ] ,
669
662
user_id ,
670
663
attributes
671
664
)
672
-
673
- variable_value
674
665
end
675
666
676
667
# 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
689
680
return nil
690
681
end
691
682
692
- variable_value = get_feature_variable_for_type (
683
+ get_feature_variable_for_type (
693
684
feature_flag_key ,
694
685
variable_key ,
695
686
Optimizely ::Helpers ::Constants ::VARIABLE_TYPES [ 'BOOLEAN' ] ,
696
687
user_id ,
697
688
attributes
698
689
)
699
-
700
- variable_value
701
690
end
702
691
703
692
# 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
716
705
return nil
717
706
end
718
707
719
- variable_value = get_feature_variable_for_type (
708
+ get_feature_variable_for_type (
720
709
feature_flag_key ,
721
710
variable_key ,
722
711
Optimizely ::Helpers ::Constants ::VARIABLE_TYPES [ 'DOUBLE' ] ,
723
712
user_id ,
724
713
attributes
725
714
)
726
-
727
- variable_value
728
715
end
729
716
730
717
# 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
809
796
return nil
810
797
end
811
798
812
- variable_value = get_feature_variable_for_type (
799
+ get_feature_variable_for_type (
813
800
feature_flag_key ,
814
801
variable_key ,
815
802
Optimizely ::Helpers ::Constants ::VARIABLE_TYPES [ 'INTEGER' ] ,
816
803
user_id ,
817
804
attributes
818
805
)
819
-
820
- variable_value
821
806
end
822
807
823
808
def is_valid
0 commit comments