Class: AmplitudeExperiment::InMemoryFlagConfigStorage

Inherits:
FlagConfigStorage show all
Defined in:
lib/experiment/flag/flag_config_storage.rb

Overview

InMemoryFlagConfigStorage

Instance Method Summary collapse

Constructor Details

#initializeInMemoryFlagConfigStorage

Returns a new instance of InMemoryFlagConfigStorage.



23
24
25
26
27
# File 'lib/experiment/flag/flag_config_storage.rb', line 23

def initialize
  super # Call the parent class's constructor with no arguments
  @flag_configs = {}
  @flag_configs_lock = Mutex.new
end

Instance Method Details

#flag_config(key) ⇒ Object



29
30
31
32
33
# File 'lib/experiment/flag/flag_config_storage.rb', line 29

def flag_config(key)
  @flag_configs_lock.synchronize do
    @flag_configs[key]
  end
end

#flag_configsObject



35
36
37
38
39
# File 'lib/experiment/flag/flag_config_storage.rb', line 35

def flag_configs
  @flag_configs_lock.synchronize do
    @flag_configs.dup
  end
end

#put_flag_config(flag_config) ⇒ Object



41
42
43
44
45
# File 'lib/experiment/flag/flag_config_storage.rb', line 41

def put_flag_config(flag_config)
  @flag_configs_lock.synchronize do
    @flag_configs[flag_config['key']] = flag_config
  end
end

#remove_ifObject



47
48
49
50
51
# File 'lib/experiment/flag/flag_config_storage.rb', line 47

def remove_if
  @flag_configs_lock.synchronize do
    @flag_configs.delete_if { |_key, value| yield(value) }
  end
end