Class: Kameleoon::Types::Variation

Inherits:
Object
  • Object
show all
Defined in:
lib/kameleoon/types/variation.rb

Overview

Variation

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_idObject (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

#idObject (readonly)

Returns the value of attribute id.



10
11
12
# File 'lib/kameleoon/types/variation.rb', line 10

def id
  @id
end

#keyObject (readonly)

Returns the value of attribute key.



10
11
12
# File 'lib/kameleoon/types/variation.rb', line 10

def key
  @key
end

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/kameleoon/types/variation.rb', line 10

def name
  @name
end

#variablesObject (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

Returns:

  • (Boolean)


36
37
38
# File 'lib/kameleoon/types/variation.rb', line 36

def active?
  @key != Configuration::VariationType::VARIATION_OFF
end

#to_sObject



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