Sha256: 775872859b541162d650cb1bbee05a01d1c7dd2f427e4bd1c2aae7710f815695
Contents?: true
Size: 800 Bytes
Versions: 1
Compression:
Stored size: 800 Bytes
Contents
module HashPersistent class Basic class << self @@store = {} @@prefix = "" def setup(store, prefix) raise ArgumentError unless store.respond_to?(:has_key?) and prefix.respond_to?(:to_s) @@store = store @@prefix = prefix end def find(key) @@store[@@prefix + key] end end attr_reader :key def initialize(key) raise RuntimeError if @@store.has_key?(key) @key = key @@store[@@prefix + @key] = self end def delete raise RuntimeError unless @@store.has_key?(@@prefix + @key) @@store.delete(@@prefix + @key) end def update raise RuntimeError unless @@store.has_key?(@@prefix + @key) @@store[@@prefix + @key] = self end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kissifer-hash-persistent-0.0.3 | lib/hash-persistent/basic.rb |