lib/mongo/collection/view/readable.rb in mongo-2.0.2 vs lib/mongo/collection/view/readable.rb in mongo-2.0.3
- old
+ new
@@ -230,10 +230,11 @@
#
# @return [ Hash, View ] Either the fields or a new +View+.
#
# @since 2.0.0
def projection(document = nil)
+ validate_doc!(document) if document
configure(:projection, document)
end
# The read preference to use for the query.
#
@@ -354,9 +355,13 @@
end
end
def to_return
[ limit || batch_size, batch_size || limit ].min
+ end
+
+ def validate_doc!(doc)
+ raise Error::InvalidDocument.new unless doc.respond_to?(:keys)
end
end
end
end
end