Class: Kameleoon::Configuration::Experiment
- Inherits:
-
Object
- Object
- Kameleoon::Configuration::Experiment
- Defined in:
- lib/kameleoon/configuration/experiment.rb
Overview
Class for manage all experiments and old feature flags
Instance Attribute Summary collapse
-
#deviations ⇒ Object
Returns the value of attribute deviations.
-
#id ⇒ Object
Returns the value of attribute id.
-
#respool_time ⇒ Object
Returns the value of attribute respool_time.
-
#site_enabled ⇒ Object
Returns the value of attribute site_enabled.
-
#status ⇒ Object
Returns the value of attribute status.
-
#targeting_segment ⇒ Object
Returns the value of attribute targeting_segment.
-
#variations ⇒ Object
Returns the value of attribute variations.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(experiment_hash) ⇒ Experiment
constructor
A new instance of Experiment.
Constructor Details
#initialize(experiment_hash) ⇒ Experiment
Returns a new instance of Experiment.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/kameleoon/configuration/experiment.rb', line 16 def initialize(experiment_hash) @id = experiment_hash['id'] @status = experiment_hash['status'] @site_enabled = experiment_hash['siteEnabled'] unless experiment_hash['deviations'].nil? @deviations = Hash[*experiment_hash['deviations'].map do |it| [it['variationId'] == 'origin' ? '0' : it['variationId'], it['value']] end.flatten] end unless experiment_hash['respoolTime'].nil? @respool_time = Hash[*experiment_hash['respoolTime'].map do |it| [it['variationId'] == 'origin' ? '0' : it['variationId'], it['value']] end.flatten] end unless experiment_hash['variations'].nil? @variations = experiment_hash['variations'].map do |it| { 'id' => it['id'].to_i, 'customJson' => it['customJson'] } end end @targeting_segment = Kameleoon::Targeting::Segment.new((experiment_hash['segment'])) if experiment_hash['segment'] end |
Instance Attribute Details
#deviations ⇒ Object
Returns the value of attribute deviations.
10 11 12 |
# File 'lib/kameleoon/configuration/experiment.rb', line 10 def deviations @deviations end |
#id ⇒ Object
Returns the value of attribute id.
10 11 12 |
# File 'lib/kameleoon/configuration/experiment.rb', line 10 def id @id end |
#respool_time ⇒ Object
Returns the value of attribute respool_time.
10 11 12 |
# File 'lib/kameleoon/configuration/experiment.rb', line 10 def respool_time @respool_time end |
#site_enabled ⇒ Object
Returns the value of attribute site_enabled.
10 11 12 |
# File 'lib/kameleoon/configuration/experiment.rb', line 10 def site_enabled @site_enabled end |
#status ⇒ Object
Returns the value of attribute status.
10 11 12 |
# File 'lib/kameleoon/configuration/experiment.rb', line 10 def status @status end |
#targeting_segment ⇒ Object
Returns the value of attribute targeting_segment.
10 11 12 |
# File 'lib/kameleoon/configuration/experiment.rb', line 10 def targeting_segment @targeting_segment end |
#variations ⇒ Object
Returns the value of attribute variations.
10 11 12 |
# File 'lib/kameleoon/configuration/experiment.rb', line 10 def variations @variations end |
Class Method Details
.create_from_array(array) ⇒ Object
12 13 14 |
# File 'lib/kameleoon/configuration/experiment.rb', line 12 def self.create_from_array(array) array&.map { |it| Experiment.new(it) } end |