Class: MemoryStorage
- Inherits:
-
Object
- Object
- MemoryStorage
- Extended by:
- Enumerable
- Defined in:
- lib/memory_storage.rb
Constant Summary collapse
- VERSION =
'0.0.1'
Class Method Summary collapse
- .all ⇒ Object
- .each(&block) ⇒ Object
- .find(identifier) ⇒ Object
- .flush ⇒ Object
- .save(object, identifier_method = :id) ⇒ Object
- .storage ⇒ Object
Class Method Details
.all ⇒ Object
19 20 21 |
# File 'lib/memory_storage.rb', line 19 def all storage.values end |
.each(&block) ⇒ Object
23 24 25 |
# File 'lib/memory_storage.rb', line 23 def each(&block) storage.values.each &block end |
.find(identifier) ⇒ Object
11 12 13 |
# File 'lib/memory_storage.rb', line 11 def find(identifier) storage[identifier] end |
.flush ⇒ Object
15 16 17 |
# File 'lib/memory_storage.rb', line 15 def flush @storage = {} end |
.save(object, identifier_method = :id) ⇒ Object
7 8 9 |
# File 'lib/memory_storage.rb', line 7 def save(object, identifier_method = :id) storage[object.send identifier_method] = object end |
.storage ⇒ Object
27 28 29 |
# File 'lib/memory_storage.rb', line 27 def storage @storage ||= {} end |