Class: Kameleoon::Types::Variation
- Inherits:
-
Object
- Object
- Kameleoon::Types::Variation
- Defined in:
- lib/kameleoon/types/variation.rb
Overview
Variation
Instance Attribute Summary collapse
-
#experiment_id ⇒ Object
readonly
Returns the value of attribute experiment_id.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#variables ⇒ Object
readonly
Returns the value of attribute variables.
Class Method Summary collapse
Instance Method Summary collapse
- #active? ⇒ Boolean
-
#initialize(key, id, experiment_id, variables, name = '') ⇒ Variation
constructor
private
A new instance of Variation.
- #to_s ⇒ Object
Constructor Details
#initialize(key, id, experiment_id, variables, name = '') ⇒ Variation
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 Variation.
17 18 19 20 21 22 23 |
# File 'lib/kameleoon/types/variation.rb', line 17 def initialize(key, id, experiment_id, variables, name = '') @key = key @id = id @experiment_id = experiment_id @variables = variables @name = name end |
Instance Attribute Details
#experiment_id ⇒ Object (readonly)
Returns the value of attribute experiment_id.
10 11 12 |
# File 'lib/kameleoon/types/variation.rb', line 10 def experiment_id @experiment_id end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'lib/kameleoon/types/variation.rb', line 10 def id @id end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
10 11 12 |
# File 'lib/kameleoon/types/variation.rb', line 10 def key @key end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/kameleoon/types/variation.rb', line 10 def name @name end |
#variables ⇒ Object (readonly)
Returns the value of attribute variables.
10 11 12 |
# File 'lib/kameleoon/types/variation.rb', line 10 def variables @variables end |
Class Method Details
._build_from_internal(source_variation, variation_id = nil, experiment_id = nil) ⇒ 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.
26 27 28 29 30 31 32 33 34 |
# File 'lib/kameleoon/types/variation.rb', line 26 def self._build_from_internal(source_variation, variation_id = nil, experiment_id = nil) variables = (source_variation&.variables || []).each_with_object({}) do |variable, result| ext_variable = Variable._build_from_internal(variable) result[ext_variable.key] = ext_variable end key = source_variation&.key || '' name = source_variation&.name || '' Variation.new(key, variation_id, experiment_id, variables, name) end |
Instance Method Details
#active? ⇒ Boolean
36 37 38 |
# File 'lib/kameleoon/types/variation.rb', line 36 def active? @key != Configuration::VariationType::VARIATION_OFF end |
#to_s ⇒ Object
12 13 14 |
# File 'lib/kameleoon/types/variation.rb', line 12 def to_s "Variation{name:'#{@name}',key:'#{@key}',id:#{@id},experiment_id:#{@experiment_id},variables:#{@variables}}" end |