class Swarm::Storage::HashStorage

Public Instance Methods

all_of_type(type, subtypes: true) click to toggle source
# File lib/swarm/storage/hash_storage.rb, line 11
def all_of_type(type, subtypes: true)
  store.select { |key, value|
    key.match(regex_for_type(type)) &&
      (subtypes || value["type"] == type)
  }.values
end
delete(key) click to toggle source
# File lib/swarm/storage/hash_storage.rb, line 18
def delete(key)
  store.delete(key)
end
ids_for_type(type) click to toggle source
# File lib/swarm/storage/hash_storage.rb, line 6
def ids_for_type(type)
  keys = store.keys.select { |key| key.match(regex_for_type(type)) }
  keys.map { |key| key.gsub(regex_for_type(type), '\1') }
end
truncate() click to toggle source
# File lib/swarm/storage/hash_storage.rb, line 22
def truncate
  store.clear
end