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.
36 37 38 |
# File 'lib/wingify/packages/segmentation_evaluator/core/segmentation_manager.rb', line 36 def initialize @evaluator = SegmentEvaluator.new end |
Instance Attribute Details
#evaluator ⇒ Object
Returns the value of attribute evaluator.
30 31 32 |
# File 'lib/wingify/packages/segmentation_evaluator/core/segmentation_manager.rb', line 30 def evaluator @evaluator end |
Class Method Details
.instance ⇒ Object
32 33 34 |
# File 'lib/wingify/packages/segmentation_evaluator/core/segmentation_manager.rb', line 32 def self.instance @@instance ||= SegmentationManager.new end |
Instance Method Details
#attach_evaluator(evaluator = nil) ⇒ Object
40 41 42 |
# File 'lib/wingify/packages/segmentation_evaluator/core/segmentation_manager.rb', line 40 def attach_evaluator(evaluator = nil) @evaluator = evaluator || SegmentEvaluator.new end |
#set_contextual_data(settings, feature, context) ⇒ Object
Set the context for the segmentation evaluator
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/wingify/packages/segmentation_evaluator/core/segmentation_manager.rb', line 48 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
74 75 76 |
# File 'lib/wingify/packages/segmentation_evaluator/core/segmentation_manager.rb', line 74 def validate_segmentation(dsl, properties) @evaluator.is_segmentation_valid(dsl, properties) end |