Class: Kameleoon::Configuration::DataFile

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(environment, configuration = nil) ⇒ DataFile

Returns a new instance of DataFile.



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/kameleoon/configuration/data_file.rb', line 24

def initialize(environment, configuration = nil)
  Logging::KameleoonLogger.debug('CALL: DataFile.new(environment: %s)', environment)
  @environment = environment
  if configuration.nil?
    init_default
  else
    init(configuration)
  end
  collect_indices
  Logging::KameleoonLogger.debug('RETURN: DataFile.new(environment: %s)', environment)
end

Instance Attribute Details

#custom_data_infoObject (readonly)

Returns the value of attribute custom_data_info.



12
13
14
# File 'lib/kameleoon/configuration/data_file.rb', line 12

def custom_data_info
  @custom_data_info
end

#experiment_ids_with_js_css_variableObject (readonly)

Returns the value of attribute experiment_ids_with_js_css_variable.



12
13
14
# File 'lib/kameleoon/configuration/data_file.rb', line 12

def experiment_ids_with_js_css_variable
  @experiment_ids_with_js_css_variable
end

#feature_flag_by_idObject (readonly)

Returns the value of attribute feature_flag_by_id.



12
13
14
# File 'lib/kameleoon/configuration/data_file.rb', line 12

def feature_flag_by_id
  @feature_flag_by_id
end

#feature_flagsObject (readonly)

Returns the value of attribute feature_flags.



12
13
14
# File 'lib/kameleoon/configuration/data_file.rb', line 12

def feature_flags
  @feature_flags
end

#has_any_targeted_delivery_ruleObject (readonly)

Returns the value of attribute has_any_targeted_delivery_rule.



12
13
14
# File 'lib/kameleoon/configuration/data_file.rb', line 12

def has_any_targeted_delivery_rule
  @has_any_targeted_delivery_rule
end

#holdoutObject (readonly)

Returns the value of attribute holdout.



12
13
14
# File 'lib/kameleoon/configuration/data_file.rb', line 12

def holdout
  @holdout
end

#rule_by_segment_idObject (readonly)

Returns the value of attribute rule_by_segment_id.



12
13
14
# File 'lib/kameleoon/configuration/data_file.rb', line 12

def rule_by_segment_id
  @rule_by_segment_id
end

#rule_info_by_exp_idObject (readonly)

Returns the value of attribute rule_info_by_exp_id.



12
13
14
# File 'lib/kameleoon/configuration/data_file.rb', line 12

def rule_info_by_exp_id
  @rule_info_by_exp_id
end

#settingsObject (readonly)

Returns the value of attribute settings.



12
13
14
# File 'lib/kameleoon/configuration/data_file.rb', line 12

def settings
  @settings
end

#variation_by_idObject (readonly)

Returns the value of attribute variation_by_id.



12
13
14
# File 'lib/kameleoon/configuration/data_file.rb', line 12

def variation_by_id
  @variation_by_id
end

Instance Method Details

#experiment_js_css_variable?(experiment_id) ⇒ Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/kameleoon/configuration/data_file.rb', line 44

def experiment_js_css_variable?(experiment_id)
  @experiment_ids_with_js_css_variable.include?(experiment_id)
end

#get_feature_flag(feature_key) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/kameleoon/configuration/data_file.rb', line 36

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

#to_sObject



16
17
18
19
20
21
22
# File 'lib/kameleoon/configuration/data_file.rb', line 16

def to_s
  'DataFile{' \
    "environment:#{@environment}," \
    "feature_flags:#{@feature_flags.size}," \
    "settings:#{@settings}" \
    '}'
end