Class: SegmentationManager
- Inherits:
-
Object
- Object
- SegmentationManager
- Defined in:
- lib/wingify/packages/segmentation_evaluator/core/segmentation_manager.rb
Constant Summary collapse
- @@instance =
Singleton instance
nil
Instance Attribute Summary collapse
-
#evaluator ⇒ Object
Returns the value of attribute evaluator.
Class Method Summary collapse
Instance Method Summary collapse
- #attach_evaluator(evaluator = nil) ⇒ Object
-
#initialize ⇒ SegmentationManager
constructor
A new instance of SegmentationManager.
-
#set_contextual_data(settings, feature, context) ⇒ Object
Set the context for the segmentation evaluator.
- #validate_segmentation(dsl, properties) ⇒ Object
Constructor Details
#initialize ⇒ SegmentationManager
Returns a new instance of SegmentationManager.
38 39 40 |
# File 'lib/wingify/packages/segmentation_evaluator/core/segmentation_manager.rb', line 38 def initialize @evaluator = SegmentEvaluator.new end |
Instance Attribute Details
#evaluator ⇒ Object
Returns the value of attribute evaluator.
32 33 34 |
# File 'lib/wingify/packages/segmentation_evaluator/core/segmentation_manager.rb', line 32 def evaluator @evaluator end |
Class Method Details
.instance ⇒ Object
34 35 36 |
# File 'lib/wingify/packages/segmentation_evaluator/core/segmentation_manager.rb', line 34 def self.instance @@instance ||= SegmentationManager.new end |
Instance Method Details
#attach_evaluator(evaluator = nil) ⇒ Object
42 43 44 |
# File 'lib/wingify/packages/segmentation_evaluator/core/segmentation_manager.rb', line 42 def attach_evaluator(evaluator = nil) @evaluator = evaluator || SegmentEvaluator.new end |
#set_contextual_data(settings, feature, context) ⇒ Object
Set the context for the segmentation evaluator
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/wingify/packages/segmentation_evaluator/core/segmentation_manager.rb', line 50 def set_contextual_data(settings, feature, context) attach_evaluator @evaluator.settings = settings @evaluator.context = context @evaluator.feature = feature # If both user agent and IP address are null, avoid making a gateway service call return if context&.get_user_agent.nil? && context&.get_ip_address.nil? if feature.get_is_gateway_service_required if SettingsService.instance.is_gateway_service_provided && (context.get_vwo.nil?) query_params = {} query_params['userAgent'] = context.get_user_agent if context&.get_user_agent query_params['ipAddress'] = context.get_ip_address if context&.get_ip_address begin params = get_query_params(query_params) vwo_data = get_from_gateway_service(params, UrlEnum::GET_USER_DATA) context.set_vwo(ContextVWOModel.new.model_from_dictionary(vwo_data)) rescue StandardError => e LoggerService.log(LogLevelEnum::ERROR, "ERROR_SETTING_SEGMENTATION_CONTEXT", { err: e., an: ApiEnum::GET_FLAG, sId: context.get_session_id, uuid: context.get_uuid}) end end end end |
#validate_segmentation(dsl, properties) ⇒ Object
76 77 78 79 80 81 82 83 84 |
# File 'lib/wingify/packages/segmentation_evaluator/core/segmentation_manager.rb', line 76 def validate_segmentation(dsl, properties) if has_campaign_variation_node?(dsl) platform_vars = @evaluator.context&.get_platform_variables web_testing_campaigns = platform_vars && (platform_vars[:webTestingCampaigns] || platform_vars['webTestingCampaigns']) return false unless web_testing_campaigns end @evaluator.is_segmentation_valid(dsl, properties) end |