Class: RST::Persistent::MemoryStore
- Defined in:
- lib/modules/persistent/memory_store.rb
Overview
# MemoryStore doesn’t really store the objects but holds them in memory, in a simple Array. Perfect for testing
Instance Method Summary collapse
- #all ⇒ Array
-
#delete! ⇒ Object
remove all objects.
-
#update(object) ⇒ Object
Find and update or add an object to the store.
Methods inherited from Store
#-, #<<, #create, #find, #first, #initialize
Constructor Details
This class inherits a constructor from RST::Persistent::Store
Instance Method Details
#all ⇒ Array
12 13 14 |
# File 'lib/modules/persistent/memory_store.rb', line 12 def all @objects || [] end |
#delete! ⇒ Object
remove all objects
24 25 26 |
# File 'lib/modules/persistent/memory_store.rb', line 24 def delete! @objects = [] end |
#update(object) ⇒ Object
Find and update or add an object to the store
18 19 20 21 |
# File 'lib/modules/persistent/memory_store.rb', line 18 def update(object) @objects -= [object] @objects << object end |