Class: MemoryStorage

Inherits:
Object
  • Object
show all
Extended by:
Enumerable
Defined in:
lib/memory_storage.rb

Constant Summary collapse

VERSION =
'0.0.1'

Class Method Summary collapse

Class Method Details

.allObject



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

.flushObject



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

.storageObject



27
28
29
# File 'lib/memory_storage.rb', line 27

def storage
  @storage ||= {}
end