Sha256: 37f790b9babe3e49a094a34cfdcf2d69e2da0b28f9c14b43e2919b07a2124640
Contents?: true
Size: 581 Bytes
Versions: 8
Compression:
Stored size: 581 Bytes
Contents
module Del class Repository def initialize(storage = {}) @storage = storage @lock = Mutex.new end def [](id) find_by(id) end def find_by(id) @lock.synchronize { @storage[id.to_s] } end def find_by_value @lock.synchronize { @storage.values.find { |x| yield x } } end def find_all @lock.synchronize { @storage.keys } end def upsert(id, attributes = {}) Del.logger.debug([id, attributes].inspect) @lock.synchronize do @storage[id.to_s] = attributes end end end end
Version data entries
8 entries across 8 versions & 1 rubygems