From e621db732e8537b6f7d6c1318460ea0857ed6310 Mon Sep 17 00:00:00 2001 From: Kyle Banker Date: Wed, 24 Nov 2010 14:01:26 -0500 Subject: [PATCH] minor: cleanup --- lib/mongo/cursor.rb | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/mongo/cursor.rb b/lib/mongo/cursor.rb index e9570ed..786cec9 100644 --- a/lib/mongo/cursor.rb +++ b/lib/mongo/cursor.rb @@ -112,19 +112,18 @@ module Mongo # # @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 - # not take limit and skip into account. + # @return [Integer] the number of objects in the result set for this query. # # @raise [OperationFailure] on a database error. - def count skip_and_limit = false - command = BSON::OrderedHash["count", @collection.name, - "query", @selector] + def count(skip_and_limit = false) + command = BSON::OrderedHash["count", @collection.name, "query", @selector] + if skip_and_limit - command.merge! BSON::OrderedHash["limit", @limit] if @limit != 0 - command.merge! BSON::OrderedHash["skip", @skip] if @skip != 0 + command.merge!(BSON::OrderedHash["limit", @limit]) if @limit != 0 + command.merge!(BSON::OrderedHash["skip", @skip]) if @skip != 0 end - command.merge! BSON::OrderedHash["fields", @fields] + command.merge!(BSON::OrderedHash["fields", @fields]) response = @db.command(command) return response['n'].to_i if Mongo::Support.ok?(response)