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