lib/mongoid/criterion/optional.rb in mongo_doc-0.6.11 vs lib/mongoid/criterion/optional.rb in mongo_doc-0.6.12
- old
+ new
@@ -1,9 +1,14 @@
# encoding: utf-8
+
+require 'mongoid/contexts/id_conversion'
+
module Mongoid #:nodoc:
module Criterion #:nodoc:
module Optional
+ include Mongoid::Contexts::IdConversion
+
# Tells the criteria that the cursor that gets returned needs to be
# cached. This is so multiple iterations don't hit the database multiple
# times, however this is not advisable when working with large data sets
# as the entire results will get stored in memory.
#
@@ -68,10 +73,11 @@
#
# <tt>criteria.id("4ab2bc4b8ad548971900005c")</tt>
#
# Returns: <tt>self</tt>
def id(*args)
- (args.flatten.size > 1) ? self.in(:_id => args.flatten) : (@selector[:_id] = args.first)
+ ids = strings_to_object_ids(args.flatten)
+ (ids.size > 1) ? self.in(:_id => ids) : (@selector[:_id] = ids.first)
self
end
# Adds a criterion to the +Criteria+ that specifies the maximum number of
# results to return. This is mostly used in conjunction with <tt>skip()</tt>