Class: Mistri::Stores::Memory
- Inherits:
-
Object
- Object
- Mistri::Stores::Memory
- Defined in:
- lib/mistri/stores/memory.rb
Overview
Entries in a plain Hash: for tests and runs that need no persistence.
Instance Method Summary collapse
- #append(id, entry) ⇒ Object
-
#initialize ⇒ Memory
constructor
A new instance of Memory.
- #load(id) ⇒ Object
Constructor Details
#initialize ⇒ Memory
Returns a new instance of Memory.
7 8 9 10 |
# File 'lib/mistri/stores/memory.rb', line 7 def initialize @entries = Hash.new { |hash, key| hash[key] = [] } @mutex = Mutex.new end |
Instance Method Details
#append(id, entry) ⇒ Object
12 13 14 15 |
# File 'lib/mistri/stores/memory.rb', line 12 def append(id, entry) @mutex.synchronize { @entries[id] << entry } nil end |
#load(id) ⇒ Object
17 18 19 |
# File 'lib/mistri/stores/memory.rb', line 17 def load(id) @mutex.synchronize { @entries[id].dup } end |