Class: Kameleoon::Configuration::DataFile
- Inherits:
-
Object
- Object
- Kameleoon::Configuration::DataFile
- Defined in:
- lib/kameleoon/configuration/data_file.rb
Instance Attribute Summary collapse
-
#custom_data_info ⇒ Object
readonly
Returns the value of attribute custom_data_info.
-
#feature_flag_by_id ⇒ Object
readonly
Returns the value of attribute feature_flag_by_id.
-
#feature_flags ⇒ Object
readonly
Returns the value of attribute feature_flags.
-
#has_any_targeted_delivery_rule ⇒ Object
readonly
Returns the value of attribute has_any_targeted_delivery_rule.
-
#rule_by_segment_id ⇒ Object
readonly
Returns the value of attribute rule_by_segment_id.
-
#settings ⇒ Object
readonly
Returns the value of attribute settings.
-
#variation_by_id ⇒ Object
readonly
Returns the value of attribute variation_by_id.
Instance Method Summary collapse
- #get_feature_flag(feature_key) ⇒ Object
- #init(configuration) ⇒ Object
-
#initialize(environment, log_func = nil) ⇒ DataFile
constructor
A new instance of DataFile.
Constructor Details
#initialize(environment, log_func = nil) ⇒ DataFile
Returns a new instance of DataFile.
13 14 15 16 17 18 19 20 |
# File 'lib/kameleoon/configuration/data_file.rb', line 13 def initialize(environment, log_func = nil) @settings = Settings.new @feature_flags = {} @environment = environment @log_func = log_func collect_indices @custom_data_info = Kameleoon::Configuration::CustomDataInfo.new(nil, @log_func) end |
Instance Attribute Details
#custom_data_info ⇒ Object (readonly)
Returns the value of attribute custom_data_info.
10 11 12 |
# File 'lib/kameleoon/configuration/data_file.rb', line 10 def custom_data_info @custom_data_info end |
#feature_flag_by_id ⇒ Object (readonly)
Returns the value of attribute feature_flag_by_id.
10 11 12 |
# File 'lib/kameleoon/configuration/data_file.rb', line 10 def feature_flag_by_id @feature_flag_by_id end |
#feature_flags ⇒ Object (readonly)
Returns the value of attribute feature_flags.
10 11 12 |
# File 'lib/kameleoon/configuration/data_file.rb', line 10 def feature_flags @feature_flags end |
#has_any_targeted_delivery_rule ⇒ Object (readonly)
Returns the value of attribute has_any_targeted_delivery_rule.
10 11 12 |
# File 'lib/kameleoon/configuration/data_file.rb', line 10 def has_any_targeted_delivery_rule @has_any_targeted_delivery_rule end |
#rule_by_segment_id ⇒ Object (readonly)
Returns the value of attribute rule_by_segment_id.
10 11 12 |
# File 'lib/kameleoon/configuration/data_file.rb', line 10 def rule_by_segment_id @rule_by_segment_id end |
#settings ⇒ Object (readonly)
Returns the value of attribute settings.
10 11 12 |
# File 'lib/kameleoon/configuration/data_file.rb', line 10 def settings @settings end |
#variation_by_id ⇒ Object (readonly)
Returns the value of attribute variation_by_id.
10 11 12 |
# File 'lib/kameleoon/configuration/data_file.rb', line 10 def variation_by_id @variation_by_id end |
Instance Method Details
#get_feature_flag(feature_key) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/kameleoon/configuration/data_file.rb', line 34 def get_feature_flag(feature_key) ff = @feature_flags[feature_key] raise Exception::FeatureNotFound, feature_key if ff.nil? raise Exception::FeatureEnvironmentDisabled.new(feature_key, @environment) unless ff.environment_enabled ff end |
#init(configuration) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/kameleoon/configuration/data_file.rb', line 22 def init(configuration) @settings.update(configuration['configuration']) configuration['featureFlags'].each do |raw| ff = FeatureFlag.new(raw) @feature_flags[ff.feature_key] = ff end @has_any_targeted_delivery_rule = any_targeted_delivery_rule? collect_indices @custom_data_info = CustomDataInfo.new(configuration['customData'], @log_func) self end |