Class: Kameleoon::Configuration::Rule
- Inherits:
-
Object
- Object
- Kameleoon::Configuration::Rule
- Defined in:
- lib/kameleoon/configuration/rule.rb
Overview
Rule is a class for new rules of feature flags
Instance Attribute Summary collapse
-
#experiment_id ⇒ Object
readonly
Returns the value of attribute experiment_id.
-
#exposition ⇒ Object
readonly
Returns the value of attribute exposition.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#order ⇒ Object
readonly
Returns the value of attribute order.
-
#respool_time ⇒ Object
readonly
Returns the value of attribute respool_time.
-
#targeting_segment ⇒ Object
Returns the value of attribute targeting_segment.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#variation_by_exposition ⇒ Object
readonly
Returns the value of attribute variation_by_exposition.
Class Method Summary collapse
Instance Method Summary collapse
- #experimentation_type? ⇒ Boolean
- #get_variation(hash_double) ⇒ Object
- #get_variation_id_by_key(key) ⇒ Object
-
#initialize(hash) ⇒ Rule
constructor
A new instance of Rule.
- #targeted_delivery_type? ⇒ Boolean
Constructor Details
#initialize(hash) ⇒ Rule
Returns a new instance of Rule.
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/kameleoon/configuration/rule.rb', line 24 def initialize(hash) @id = hash['id'] @order = hash['order'] @type = hash['type'] @exposition = hash['exposition'] @experiment_id = hash['experimentId'] @respool_time = hash['respoolTime'] @variation_by_exposition = VariationByExposition.create_from_array(hash['variationByExposition']) @targeting_segment = Kameleoon::Targeting::Segment.new((hash['segment'])) if hash['segment'] end |
Instance Attribute Details
#experiment_id ⇒ Object (readonly)
Returns the value of attribute experiment_id.
17 18 19 |
# File 'lib/kameleoon/configuration/rule.rb', line 17 def experiment_id @experiment_id end |
#exposition ⇒ Object (readonly)
Returns the value of attribute exposition.
17 18 19 |
# File 'lib/kameleoon/configuration/rule.rb', line 17 def exposition @exposition end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
17 18 19 |
# File 'lib/kameleoon/configuration/rule.rb', line 17 def id @id end |
#order ⇒ Object (readonly)
Returns the value of attribute order.
17 18 19 |
# File 'lib/kameleoon/configuration/rule.rb', line 17 def order @order end |
#respool_time ⇒ Object (readonly)
Returns the value of attribute respool_time.
17 18 19 |
# File 'lib/kameleoon/configuration/rule.rb', line 17 def respool_time @respool_time end |
#targeting_segment ⇒ Object
Returns the value of attribute targeting_segment.
18 19 20 |
# File 'lib/kameleoon/configuration/rule.rb', line 18 def targeting_segment @targeting_segment end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
17 18 19 |
# File 'lib/kameleoon/configuration/rule.rb', line 17 def type @type end |
#variation_by_exposition ⇒ Object (readonly)
Returns the value of attribute variation_by_exposition.
17 18 19 |
# File 'lib/kameleoon/configuration/rule.rb', line 17 def variation_by_exposition @variation_by_exposition end |
Class Method Details
Instance Method Details
#experimentation_type? ⇒ Boolean
48 49 50 |
# File 'lib/kameleoon/configuration/rule.rb', line 48 def experimentation_type? @type == RuleType::EXPERIMENTATION end |
#get_variation(hash_double) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/kameleoon/configuration/rule.rb', line 35 def get_variation(hash_double) total = 0.0 variation_by_exposition.each do |var_by_exp| total += var_by_exp.exposition return var_by_exp if total >= hash_double end nil end |
#get_variation_id_by_key(key) ⇒ Object
44 45 46 |
# File 'lib/kameleoon/configuration/rule.rb', line 44 def get_variation_id_by_key(key) variation_by_exposition.select { |v| v.variation_key == key }.first&.variation_id end |
#targeted_delivery_type? ⇒ Boolean
52 53 54 |
# File 'lib/kameleoon/configuration/rule.rb', line 52 def targeted_delivery_type? @type == RuleType::TARGETED_DELIVERY end |