Sha256: afd55ab783858c4d8f5a5e668b9d99dab83152f34ecb820c911f8dbb13408d0e
Contents?: true
Size: 548 Bytes
Versions: 30
Compression:
Stored size: 548 Bytes
Contents
class Cistern::Data::Hash Cistern::Data.backends[:hash] = self def initialize(options={}, &default) @hash = Hash.new @default = default end def clear hash.clear end def store(key, *args) assign_default(key) hash.store(key, *args) end alias []= store def fetch(key, *args) assign_default(key) hash.fetch(key, *args) end alias [] fetch protected attr_reader :hash, :default def assign_default(key) if !hash.key?(key) && default default.call(hash, key) end end end
Version data entries
30 entries across 30 versions & 1 rubygems