minor: cleanup

This commit is contained in:
Kyle Banker 2010-11-24 14:01:26 -05:00
parent df80704f77
commit e621db732e

View File

@ -112,19 +112,18 @@ module Mongo
# #
# @param [Boolean] whether of not to take notice of skip and limit # @param [Boolean] whether of not to take notice of skip and limit
# #
# @return [Integer] the number of objects in the result set for this query. Does # @return [Integer] the number of objects in the result set for this query.
# not take limit and skip into account.
# #
# @raise [OperationFailure] on a database error. # @raise [OperationFailure] on a database error.
def count skip_and_limit = false def count(skip_and_limit = false)
command = BSON::OrderedHash["count", @collection.name, command = BSON::OrderedHash["count", @collection.name, "query", @selector]
"query", @selector]
if skip_and_limit if skip_and_limit
command.merge! BSON::OrderedHash["limit", @limit] if @limit != 0 command.merge!(BSON::OrderedHash["limit", @limit]) if @limit != 0
command.merge! BSON::OrderedHash["skip", @skip] if @skip != 0 command.merge!(BSON::OrderedHash["skip", @skip]) if @skip != 0
end end
command.merge! BSON::OrderedHash["fields", @fields] command.merge!(BSON::OrderedHash["fields", @fields])
response = @db.command(command) response = @db.command(command)
return response['n'].to_i if Mongo::Support.ok?(response) return response['n'].to_i if Mongo::Support.ok?(response)