Class: RST::Persistent::MemoryStore

Inherits:
Store
  • Object
show all
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

Methods inherited from Store

#-, #<<, #create, #find, #first, #initialize

Constructor Details

This class inherits a constructor from RST::Persistent::Store

Instance Method Details

#allArray

Returns:

  • (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

Parameters:

  • object (Object)


18
19
20
21
# File 'lib/modules/persistent/memory_store.rb', line 18

def update(object)
  @objects -= [object]
  @objects << object
end