Sha256: 8cf8f104de06167a90ff05d5d31e42bf78f783b85119e030cf8b1da8324a8727
Contents?: true
Size: 753 Bytes
Versions: 3
Compression:
Stored size: 753 Bytes
Contents
module Toy module Querying extend ActiveSupport::Concern module ClassMethods def get(id) log_operation(:get, self, store, id) load(id, store.read(id)) end def get!(id) get(id) || raise(Toy::NotFound.new(id)) end def get_multi(*ids) ids.flatten.map { |id| get(id) } end def get_or_new(id) get(id) || new(:id => id) end def get_or_create(id) get(id) || create(:id => id) end def key?(id) log_operation(:key, self, store, id) store.key?(id) end alias :has_key? :key? def load(id, attrs) attrs && allocate.initialize_from_database(attrs.update('id' => id)) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
toystore-0.8.3 | lib/toy/querying.rb |
toystore-0.8.2 | lib/toy/querying.rb |
toystore-0.8.1 | lib/toy/querying.rb |