lib/toy/querying.rb in toystore-0.12.0 vs lib/toy/querying.rb in toystore-0.13.0
- old
+ new
@@ -1,35 +1,34 @@
module Toy
module Querying
extend ActiveSupport::Concern
module ClassMethods
- def get(id)
- if (attrs = adapter.read(id))
+ def get(id, options = nil)
+ if (attrs = adapter.read(id, options))
load(id, attrs)
end
end
alias_method :read, :get
alias_method :find, :get
- def get!(id)
- get(id) || raise(Toy::NotFound.new(id))
+ def get!(id, options = nil)
+ get(id, options) || raise(Toy::NotFound.new(id))
end
alias_method :read!, :get!
alias_method :find!, :get!
- def get_multiple(*ids)
- result = adapter.read_multiple(*ids.flatten)
+ def get_multiple(ids, options = nil)
+ result = adapter.read_multiple(ids, options)
result.each do |id, attrs|
result[id] = attrs.nil? ? nil : load(id, attrs)
end
result
end
- alias_method :get_multi, :get_multiple
alias_method :read_multiple, :get_multiple
alias_method :find_multiple, :get_multiple
def get_or_new(id)
get(id) || new(:id => id)
@@ -37,11 +36,11 @@
def get_or_create(id)
get(id) || create(:id => id)
end
- def key?(id)
- adapter.key?(id)
+ def key?(id, options = nil)
+ adapter.key?(id, options)
end
alias :has_key? :key?
def load(id, attrs)
attrs ||= {}