Class: Kameleoon::Configuration::Variation

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

Overview

Variation of feature flag

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Variation

Returns a new instance of Variation.



21
22
23
24
# File 'lib/kameleoon/configuration/variation.rb', line 21

def initialize(hash)
  @key = hash['key']
  @variables = Variable.create_from_array(hash['variables'])
end

Instance Attribute Details

#keyObject

Returns the value of attribute key.



15
16
17
# File 'lib/kameleoon/configuration/variation.rb', line 15

def key
  @key
end

#variablesObject

Returns the value of attribute variables.



15
16
17
# File 'lib/kameleoon/configuration/variation.rb', line 15

def variables
  @variables
end

Class Method Details

.create_from_array(array) ⇒ Object



17
18
19
# File 'lib/kameleoon/configuration/variation.rb', line 17

def self.create_from_array(array)
  array&.map { |it| Variation.new(it) }
end

Instance Method Details

#get_variable_by_key(key) ⇒ Object



26
27
28
# File 'lib/kameleoon/configuration/variation.rb', line 26

def get_variable_by_key(key)
  variables.select { |var| var.key == key }.first
end