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 ⇒ Object
readonly
Returns the value of attribute experiment.
-
#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.
-
#segment_id ⇒ Object
readonly
Returns the value of attribute segment_id.
-
#targeting_segment ⇒ Object
Returns the value of attribute targeting_segment.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #experimentation_type? ⇒ Boolean
-
#initialize(hash, segments) ⇒ Rule
constructor
A new instance of Rule.
- #targeted_delivery_type? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(hash, segments) ⇒ Rule
Returns a new instance of Rule.
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/kameleoon/configuration/rule.rb', line 42 def initialize(hash, segments) @id = hash['id'] @order = hash['order'] @type = RuleType.from_literal(hash['type']) @exposition = hash['exposition'] @respool_time = hash['respoolTime'] @segment_id = hash['segmentId'] || -1 @targeting_segment = segments[@segment_id] if @segment_id != -1 @experiment = Experiment.from_json(hash) end |
Instance Attribute Details
#experiment ⇒ Object (readonly)
Returns the value of attribute experiment.
31 32 33 |
# File 'lib/kameleoon/configuration/rule.rb', line 31 def experiment @experiment end |
#exposition ⇒ Object (readonly)
Returns the value of attribute exposition.
31 32 33 |
# File 'lib/kameleoon/configuration/rule.rb', line 31 def exposition @exposition end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
31 32 33 |
# File 'lib/kameleoon/configuration/rule.rb', line 31 def id @id end |
#order ⇒ Object (readonly)
Returns the value of attribute order.
31 32 33 |
# File 'lib/kameleoon/configuration/rule.rb', line 31 def order @order end |
#respool_time ⇒ Object (readonly)
Returns the value of attribute respool_time.
31 32 33 |
# File 'lib/kameleoon/configuration/rule.rb', line 31 def respool_time @respool_time end |
#segment_id ⇒ Object (readonly)
Returns the value of attribute segment_id.
31 32 33 |
# File 'lib/kameleoon/configuration/rule.rb', line 31 def segment_id @segment_id end |
#targeting_segment ⇒ Object
Returns the value of attribute targeting_segment.
32 33 34 |
# File 'lib/kameleoon/configuration/rule.rb', line 32 def targeting_segment @targeting_segment end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
31 32 33 |
# File 'lib/kameleoon/configuration/rule.rb', line 31 def type @type end |
Class Method Details
.create_from_array(array, segments) ⇒ Object
34 35 36 |
# File 'lib/kameleoon/configuration/rule.rb', line 34 def self.create_from_array(array, segments) array&.map { |it| Rule.new(it, segments) } end |
Instance Method Details
#experimentation_type? ⇒ Boolean
53 54 55 |
# File 'lib/kameleoon/configuration/rule.rb', line 53 def experimentation_type? @type == RuleType::EXPERIMENTATION end |
#targeted_delivery_type? ⇒ Boolean
57 58 59 |
# File 'lib/kameleoon/configuration/rule.rb', line 57 def targeted_delivery_type? @type == RuleType::TARGETED_DELIVERY end |
#to_s ⇒ Object
38 39 40 |
# File 'lib/kameleoon/configuration/rule.rb', line 38 def to_s "Rule{id:#{@id}}" end |