class RST::Persistent::MemoryStore
# MemoryStore
doesn’t really store the objects but holds them in memory, in a simple Array. Perfect for testing @api persistent
Public Instance Methods
all()
click to toggle source
@return [Array]
# File lib/modules/persistent/memory_store.rb, line 12 def all @objects || [] end
delete!()
click to toggle source
remove all objects
# File lib/modules/persistent/memory_store.rb, line 24 def delete! @objects = [] end
update(object)
click to toggle source
Find and update or add an object to the store @param [Object] object
# File lib/modules/persistent/memory_store.rb, line 18 def update(object) @objects -= [object] @objects << object end
Private Instance Methods
remove_object(object)
click to toggle source
@param [Object] object - the object to be removed
# File lib/modules/persistent/memory_store.rb, line 36 def remove_object(object) @objects -= [object] end
setup_backend()
click to toggle source
Initialize an empty array as an in-memory-store
# File lib/modules/persistent/memory_store.rb, line 31 def setup_backend @objects = [] end
sync_store()
click to toggle source
Make sure the current state of objects is stored @abstract - Overwrite in descendants thus every object gets persistently stored.
# File lib/modules/persistent/memory_store.rb, line 42 def sync_store #noop for MemoryStore end