lib/mongo_mapper/plugins/querying.rb in mongo_mapper-0.11.0 vs lib/mongo_mapper/plugins/querying.rb in mongo_mapper-0.11.1
- old
+ new
@@ -6,12 +6,15 @@
module Plugins
module Querying
extend ActiveSupport::Concern
module ClassMethods
+ extend Forwardable
include PluckyMethods
+ def_delegators :query, :to_a, :size, :empty?
+
def find_each(opts={})
super(opts).each { |doc| yield(doc) }
end
def find_by_id(id)
@@ -79,11 +82,11 @@
@transformer ||= lambda { |doc| load(doc) }
end
def find_some(ids, options={})
query = query(options).amend(:_id => ids.flatten.compact.uniq)
- find_many(query.to_hash).compact
+ query.all
end
def find_some!(ids, options={})
ids = ids.flatten.compact.uniq
docs = find_some(ids, options)
@@ -91,19 +94,9 @@
if ids.size != docs.size
raise DocumentNotFound, "Couldn't find all of the ids (#{ids.to_sentence}). Found #{docs.size}, but was expecting #{ids.size}"
end
docs
- end
-
- # All query methods that load documents pass through find_one or find_many
- def find_one(options={})
- query(options).first
- end
-
- # All query methods that load documents pass through find_one or find_many
- def find_many(options)
- query(options).all
end
def initialize_each(*docs)
instances = []
docs = [{}] if docs.blank?
\ No newline at end of file