Class: Kameleoon::Configuration::FeatureFlag
- Inherits:
-
Object
- Object
- Kameleoon::Configuration::FeatureFlag
- Defined in:
- lib/kameleoon/configuration/feature_flag.rb
Overview
Class for manage all feature flags with rules
Instance Attribute Summary collapse
-
#default_variation_key ⇒ Object
Returns the value of attribute default_variation_key.
-
#environment_enabled ⇒ Object
Returns the value of attribute environment_enabled.
-
#feature_key ⇒ Object
Returns the value of attribute feature_key.
-
#id ⇒ Object
Returns the value of attribute id.
-
#rules ⇒ Object
Returns the value of attribute rules.
-
#variations ⇒ Object
Returns the value of attribute variations.
Class Method Summary collapse
Instance Method Summary collapse
- #get_variation_by_key(key) ⇒ Object
-
#initialize(hash) ⇒ FeatureFlag
constructor
A new instance of FeatureFlag.
- #to_s ⇒ Object
Constructor Details
#initialize(hash) ⇒ FeatureFlag
Returns a new instance of FeatureFlag.
27 28 29 30 31 32 33 34 |
# File 'lib/kameleoon/configuration/feature_flag.rb', line 27 def initialize(hash) @id = hash['id'] @feature_key = hash['featureKey'] @variations = Variation.create_from_array(hash['variations']) @default_variation_key = hash['defaultVariationKey'] @environment_enabled = hash['environmentEnabled'] @rules = Rule.create_from_array(hash['rules']) end |
Instance Attribute Details
#default_variation_key ⇒ Object
Returns the value of attribute default_variation_key.
11 12 13 |
# File 'lib/kameleoon/configuration/feature_flag.rb', line 11 def default_variation_key @default_variation_key end |
#environment_enabled ⇒ Object
Returns the value of attribute environment_enabled.
11 12 13 |
# File 'lib/kameleoon/configuration/feature_flag.rb', line 11 def environment_enabled @environment_enabled end |
#feature_key ⇒ Object
Returns the value of attribute feature_key.
11 12 13 |
# File 'lib/kameleoon/configuration/feature_flag.rb', line 11 def feature_key @feature_key end |
#id ⇒ Object
Returns the value of attribute id.
11 12 13 |
# File 'lib/kameleoon/configuration/feature_flag.rb', line 11 def id @id end |
#rules ⇒ Object
Returns the value of attribute rules.
11 12 13 |
# File 'lib/kameleoon/configuration/feature_flag.rb', line 11 def rules @rules end |
#variations ⇒ Object
Returns the value of attribute variations.
11 12 13 |
# File 'lib/kameleoon/configuration/feature_flag.rb', line 11 def variations @variations end |
Class Method Details
.create_from_array(array) ⇒ Object
13 14 15 |
# File 'lib/kameleoon/configuration/feature_flag.rb', line 13 def self.create_from_array(array) array&.map { |it| FeatureFlag.new(it) } end |
Instance Method Details
#get_variation_by_key(key) ⇒ Object
36 37 38 |
# File 'lib/kameleoon/configuration/feature_flag.rb', line 36 def get_variation_by_key(key) variations.select { |v| v.key == key }.first end |
#to_s ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/kameleoon/configuration/feature_flag.rb', line 17 def to_s 'FeatureFlag{' \ "id:#{@id}, " \ "feature_key:#{@feature_key}, " \ "environment_enabled:#{@environment_enabled}, " \ "default_variation_key:#{@default_variation_key}, " \ "rules:#{@rules.size}" \ '}' end |