Class: BlueprintConfig::Backend::Memory
- Defined in:
- lib/blueprint_config/backend/memory.rb
Instance Method Summary collapse
- #clear ⇒ Object
- #fresh? ⇒ Boolean
-
#initialize ⇒ Memory
constructor
A new instance of Memory.
- #load_keys ⇒ Object
- #set(key, value) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize ⇒ Memory
Returns a new instance of Memory.
6 7 8 9 |
# File 'lib/blueprint_config/backend/memory.rb', line 6 def initialize super @store = {} end |
Instance Method Details
#clear ⇒ Object
26 27 28 |
# File 'lib/blueprint_config/backend/memory.rb', line 26 def clear @store.clear end |
#fresh? ⇒ Boolean
30 31 32 |
# File 'lib/blueprint_config/backend/memory.rb', line 30 def fresh? true end |
#load_keys ⇒ Object
11 12 13 14 |
# File 'lib/blueprint_config/backend/memory.rb', line 11 def load_keys # Return the flattened store which will be nested by BlueprintConfig nest_hash(@store, '.') end |
#set(key, value) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/blueprint_config/backend/memory.rb', line 16 def set(key, value) if value.is_a?(Hash) # Handle nested hashes - store them properly for nested access nested_hash = flatten_hash(value, key.to_s) @store.merge!(nested_hash) else @store[key.to_s] = value end end |