Class: ConfigCat::LocalDictionaryDataSource

Inherits:
OverrideDataSource show all
Defined in:
lib/configcat/localdictionarydatasource.rb

Instance Method Summary collapse

Methods inherited from OverrideDataSource

#get_behaviour

Constructor Details

#initialize(source, override_behaviour) ⇒ LocalDictionaryDataSource

Returns a new instance of LocalDictionaryDataSource.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/configcat/localdictionarydatasource.rb', line 18

def initialize(source, override_behaviour)
  super(override_behaviour)
  @_config = {}
  source.each do |key, value|
    value_type = case value
                 when TrueClass, FalseClass
                   BOOL_VALUE
                 when String
                   STRING_VALUE
                 when Integer
                   INT_VALUE
                 when Float
                   DOUBLE_VALUE
                 else
                   UNSUPPORTED_VALUE
    end

    @_config[FEATURE_FLAGS] ||= {}
    @_config[FEATURE_FLAGS][key] = { VALUE => { value_type => value } }
    setting_type = SettingType.from_type(value.class)
    @_config[FEATURE_FLAGS][key][SETTING_TYPE] = setting_type.to_i unless setting_type.nil?
  end
end

Instance Method Details

#get_overridesObject



42
43
44
# File 'lib/configcat/localdictionarydatasource.rb', line 42

def get_overrides
  return @_config
end