Class: Kameleoon::Targeting::TargetFeatureFlagCondition Private

Inherits:
Condition
  • Object
show all
Includes:
Exception
Defined in:
lib/kameleoon/targeting/conditions/target_feature_flag_condition.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

TargetExperiment represents an instance of Experiment condition in user account

Instance Attribute Summary

Attributes inherited from Condition

#id, #include, #type

Instance Method Summary collapse

Constructor Details

#initialize(json_condition) ⇒ TargetFeatureFlagCondition

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of TargetFeatureFlagCondition.



13
14
15
16
17
18
19
# File 'lib/kameleoon/targeting/conditions/target_feature_flag_condition.rb', line 13

def initialize(json_condition)
  super(json_condition)

  @feature_flag_id = json_condition['featureFlagId']
  @condition_variation_key = json_condition['variationKey']
  @condition_rule_id = json_condition['ruleId']
end

Instance Method Details

#check(data) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



21
22
23
24
25
# File 'lib/kameleoon/targeting/conditions/target_feature_flag_condition.rb', line 21

def check(data)
  return false unless data.is_a?(Kameleoon::Targeting::TargetFeatureFlagInfo) && data.variations_storage.size != 0

  get_rules(data).any? { |rule| check_rule(data, rule) }
end

#get_rules(data) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



44
45
46
47
# File 'lib/kameleoon/targeting/conditions/target_feature_flag_condition.rb', line 44

def get_rules(data)
  feature_flag = data.data_file.feature_flag_by_id[@feature_flag_id]
  feature_flag&.rules || []
end