Class: AmplitudeExperiment::InMemoryFlagConfigStorage
- Inherits:
-
FlagConfigStorage
- Object
- FlagConfigStorage
- AmplitudeExperiment::InMemoryFlagConfigStorage
- Defined in:
- lib/experiment/flag/flag_config_storage.rb
Overview
InMemoryFlagConfigStorage
Instance Method Summary collapse
- #flag_config(key) ⇒ Object
- #flag_configs ⇒ Object
-
#initialize ⇒ InMemoryFlagConfigStorage
constructor
A new instance of InMemoryFlagConfigStorage.
- #put_flag_config(flag_config) ⇒ Object
- #remove_if ⇒ Object
Constructor Details
#initialize ⇒ InMemoryFlagConfigStorage
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_configs ⇒ Object
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_if ⇒ Object
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 |