Class: KeyValueTree::MemoryStore

Inherits:
Store
  • Object
show all
Defined in:
lib/keyvaluetree/memory_store.rb

Instance Method Summary collapse

Methods inherited from Store

#delete, #delete_keys_start_with, #keys_starting_with

Constructor Details

#initialize(hash = {}) ⇒ MemoryStore

Returns a new instance of MemoryStore.



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

def initialize(hash={})
  @hash = hash
end

Instance Method Details

#basic_delete(key) ⇒ Object



17
18
19
# File 'lib/keyvaluetree/memory_store.rb', line 17

def basic_delete(key)
  @hash.delete(key.to_s)
end

#key(key) ⇒ Object



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

def key(key)
  @hash[key.to_s]
end

#keysObject



21
22
23
# File 'lib/keyvaluetree/memory_store.rb', line 21

def keys
  @hash.keys
end

#store(key, value) ⇒ Object



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

def store(key, value)
  @hash[key.to_s] = value
end

#to_hashObject



25
26
27
# File 'lib/keyvaluetree/memory_store.rb', line 25

def to_hash
  @hash
end