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
-
#bucketing_custom_data_index ⇒ Object
readonly
Returns the value of attribute bucketing_custom_data_index.
-
#default_variation_key ⇒ Object
readonly
Returns the value of attribute default_variation_key.
-
#environment_enabled ⇒ Object
readonly
Returns the value of attribute environment_enabled.
-
#feature_key ⇒ Object
readonly
Returns the value of attribute feature_key.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#me_group_name ⇒ Object
readonly
Returns the value of attribute me_group_name.
-
#rules ⇒ Object
readonly
Returns the value of attribute rules.
-
#variations ⇒ Object
readonly
Returns the value of attribute variations.
Class Method Summary collapse
Instance Method Summary collapse
- #get_variation_by_key(key) ⇒ Object
-
#initialize(hash, segments, cdi) ⇒ FeatureFlag
constructor
A new instance of FeatureFlag.
- #to_s ⇒ Object
Constructor Details
#initialize(hash, segments, cdi) ⇒ FeatureFlag
Returns a new instance of FeatureFlag.
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/kameleoon/configuration/feature_flag.rb', line 30 def initialize(hash, segments, cdi) @id = hash['id'] @feature_key = hash['featureKey'] @variations = Variation.create_from_array(hash['variations']) @default_variation_key = hash['defaultVariationKey'] @me_group_name = hash['mutuallyExclusiveGroup'] @environment_enabled = hash['environmentEnabled'] @rules = Rule.create_from_array(hash['rules'], segments) bucketing_cd_id = hash['bucketingCustomDataId'] @bucketing_custom_data_index = bucketing_cd_id ? cdi.get_custom_data_index_by_id(bucketing_cd_id) : nil end |
Instance Attribute Details
#bucketing_custom_data_index ⇒ Object (readonly)
Returns the value of attribute bucketing_custom_data_index.
11 12 13 |
# File 'lib/kameleoon/configuration/feature_flag.rb', line 11 def bucketing_custom_data_index @bucketing_custom_data_index end |
#default_variation_key ⇒ Object (readonly)
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 (readonly)
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 (readonly)
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 (readonly)
Returns the value of attribute id.
11 12 13 |
# File 'lib/kameleoon/configuration/feature_flag.rb', line 11 def id @id end |
#me_group_name ⇒ Object (readonly)
Returns the value of attribute me_group_name.
11 12 13 |
# File 'lib/kameleoon/configuration/feature_flag.rb', line 11 def me_group_name @me_group_name end |
#rules ⇒ Object (readonly)
Returns the value of attribute rules.
11 12 13 |
# File 'lib/kameleoon/configuration/feature_flag.rb', line 11 def rules @rules end |
#variations ⇒ Object (readonly)
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
14 15 16 |
# File 'lib/kameleoon/configuration/feature_flag.rb', line 14 def self.create_from_array(array) array&.map { |it| FeatureFlag.new(it) } end |
Instance Method Details
#get_variation_by_key(key) ⇒ Object
42 43 44 |
# File 'lib/kameleoon/configuration/feature_flag.rb', line 42 def get_variation_by_key(key) variations.select { |v| v.key == key }.first end |
#to_s ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/kameleoon/configuration/feature_flag.rb', line 18 def to_s 'FeatureFlag{' \ "id:#{@id}," \ "feature_key:'#{@feature_key}'," \ "environment_enabled:#{@environment_enabled}," \ "default_variation_key:'#{@default_variation_key}'," \ "me_group_name:'#{@me_group_name}'," \ "rules:#{@rules.size}," \ "bucketing_custom_data_index:#{@bucketing_custom_data_index}" \ '}' end |