Class: Enum::MemoryStore

Inherits:
Object
  • Object
show all
Defined in:
lib/enum/store/memory_store.rb

Instance Method Summary collapse

Constructor Details

#initialize(store = nil) ⇒ MemoryStore

Returns a new instance of MemoryStore.



5
6
7
# File 'lib/enum/store/memory_store.rb', line 5

def initialize(store = nil)
  @store = store || Hash.new
end

Instance Method Details

#get_value(key) ⇒ Object



9
10
11
# File 'lib/enum/store/memory_store.rb', line 9

def get_value(key)
  @store.fetch(key) rescue fail_fetch(key)
end

#set_value(name, value) ⇒ Object



13
14
15
# File 'lib/enum/store/memory_store.rb', line 13

def set_value(name, value)
  @store[name] = value
end