Class: Persistable::MemoryAdapter
- Inherits:
-
Object
- Object
- Persistable::MemoryAdapter
- Defined in:
- lib/persistable/memory_adapter.rb
Instance Method Summary collapse
- #delete(persistable) ⇒ Object
-
#initialize(options = {}) ⇒ MemoryAdapter
constructor
Options are not used in this case, but we implement the constructor header in the same way the other adapters implement it.
- #read(persistable) ⇒ Object
- #write(persistable) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ MemoryAdapter
Options are not used in this case, but we implement the constructor header in the same way the other adapters implement it.
6 7 8 |
# File 'lib/persistable/memory_adapter.rb', line 6 def initialize( = {}) @storage = {} end |
Instance Method Details
#delete(persistable) ⇒ Object
18 19 20 |
# File 'lib/persistable/memory_adapter.rb', line 18 def delete(persistable) @storage.delete(persistable.persistence_key) end |
#read(persistable) ⇒ Object
14 15 16 |
# File 'lib/persistable/memory_adapter.rb', line 14 def read(persistable) persistable.persistence_data = @storage[persistable.persistence_key] end |
#write(persistable) ⇒ Object
10 11 12 |
# File 'lib/persistable/memory_adapter.rb', line 10 def write(persistable) @storage[persistable.persistence_key] = persistable.persistence_data end |