class KeyValueTree::Store
This class defines the methods expected by KeyValueTree::Hash
for it's Store
backend
Public Instance Methods
Delete the given key @param [String]key The key to delete @return [String] The value for key or nil
# File lib/keyvaluetree/store.rb, line 26 def delete(key) raise NotImplementedError end
Delete all keys starting with the given prefix @param [String]key The key prefix @return nil
# File lib/keyvaluetree/store.rb, line 52 def delete_all(key) keys_starting_with(key.to_s).each do |each| self.delete(each) end end
Return the value for the given key @param [String]key The key to fetch @return [String] The value for key or nil
# File lib/keyvaluetree/store.rb, line 11 def key(key) raise NotImplementedError end
Fetch all keys in store @return [Array<String>] All keys in store
# File lib/keyvaluetree/store.rb, line 36 def keys raise NotImplementedError end
Fetch all keys in store with the given key prefix @param [String]key The key prefix @return [Array<String>] All keys in store
# File lib/keyvaluetree/store.rb, line 43 def keys_starting_with(key) self.keys.select do |sub_key| sub_key.start_with?(key.to_s) end end
Store
the value at the given key @param [String]key The key to store @param [String]value The value to store @return [String] The value
# File lib/keyvaluetree/store.rb, line 19 def store(key, value) raise NotImplementedError end
Convert the store to a hierachical Hash
return [Hash]
# File lib/keyvaluetree/store.rb, line 60 def to_hash raise NotImplementedError end