class Snowden::Backends::HashBackend
Public Class Methods
new(namespace="", hash=SNOWDEN_BACKEND_HASH)
click to toggle source
Creates a new redis backend
@param namespace [String] the string this backend is namespaced under. @param hash [Hash] a Hash object instance to save values in.
# File lib/snowden/backends/hash_backend.rb, line 11 def initialize(namespace="", hash=SNOWDEN_BACKEND_HASH) @namespace = namespace @hash = hash end
Public Instance Methods
find(key)
click to toggle source
Finds a value in this index
@param key [String] the string key to search the index for. @return [ [String] ] a list of strings that matched the namespaced key.
# File lib/snowden/backends/hash_backend.rb, line 30 def find(key) @hash.fetch(namespaced_key(key), []) end
save(key, value)
click to toggle source
Saves a value in this index
@param key [String] the string key to save the value under. @param value [String] the value to save.
# File lib/snowden/backends/hash_backend.rb, line 20 def save(key, value) @hash[namespaced_key(key)] ||= [] @hash[namespaced_key(key)] << value nil end
Private Instance Methods
namespaced_key(key)
click to toggle source
# File lib/snowden/backends/hash_backend.rb, line 36 def namespaced_key(key) [@namespace, key] end