Sha256: d7314bd95bda6f8de340a484c9d09008748af30276b810c504bd9a023f477242
Contents?: true
Size: 630 Bytes
Versions: 2
Compression:
Stored size: 630 Bytes
Contents
require 'singleton' module Sprig class SprigRecordStore include Singleton class RecordNotFoundError < StandardError;end def save(record, sprig_id) records_of_klass(record.class)[sprig_id.to_s] = record end def get(klass, sprig_id) records_of_klass(klass)[sprig_id.to_s] || record_not_found end private def records_of_klass(klass) records[klass.name.tableize] ||= {} end def records @records ||= {} end def record_not_found raise(RecordNotFoundError, "Record for class #{klass} and sprig_id #{sprig_id} could not be found.") end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sprig-0.1.1 | lib/sprig/sprig_record_store.rb |
sprig-0.1.0 | lib/sprig/sprig_record_store.rb |