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
Returns the value of attribute experiment_id.
-
#exposition ⇒ Object
Returns the value of attribute exposition.
-
#targeting_segment ⇒ Object
Returns the value of attribute targeting_segment.
-
#type ⇒ Object
Returns the value of attribute type.
-
#variation_by_exposition ⇒ Object
Returns the value of attribute variation_by_exposition.
Class Method Summary collapse
Instance Method Summary collapse
- #get_variation_id_by_key(key) ⇒ Object
- #get_variation_key(hash_double) ⇒ Object
-
#initialize(hash) ⇒ Rule
constructor
A new instance of Rule.
Constructor Details
#initialize(hash) ⇒ Rule
Returns a new instance of Rule.
23 24 25 26 27 28 29 |
# File 'lib/kameleoon/configuration/rule.rb', line 23 def initialize(hash) @type = hash['type'] @exposition = hash['exposition'] @experiment_id = hash['experimentId'] @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
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
Returns the value of attribute exposition.
17 18 19 |
# File 'lib/kameleoon/configuration/rule.rb', line 17 def exposition @exposition end |
#targeting_segment ⇒ Object
Returns the value of attribute targeting_segment.
17 18 19 |
# File 'lib/kameleoon/configuration/rule.rb', line 17 def targeting_segment @targeting_segment end |
#type ⇒ Object
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
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
#get_variation_id_by_key(key) ⇒ Object
40 41 42 |
# File 'lib/kameleoon/configuration/rule.rb', line 40 def get_variation_id_by_key(key) variation_by_exposition.select { |v| v.variation_key == key }.first&.variation_id end |
#get_variation_key(hash_double) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/kameleoon/configuration/rule.rb', line 31 def get_variation_key(hash_double) total = 0.0 variation_by_exposition.each do |element| total += element.exposition return element.variation_key if total >= hash_double end nil end |