minor: removed deprecated group argument

This commit is contained in:
Kyle Banker 2010-04-05 17:30:51 -04:00
parent d2be7e35a3
commit a4c72ffa5d
2 changed files with 2 additions and 15 deletions

View File

@ -462,19 +462,9 @@ module Mongo
# @param [String, BSON::Code] finalize :: optional. a JavaScript function that receives and modifies # @param [String, BSON::Code] finalize :: optional. a JavaScript function that receives and modifies
# each of the resultant grouped objects. Available only when group is run # each of the resultant grouped objects. Available only when group is run
# with command set to true. # with command set to true.
# @param [Nil] deprecated this param in a placeholder for a deprecated param. It will be removed
# in the next release.
# #
# @return [Array] the grouped items. # @return [Array] the grouped items.
def group(key, condition, initial, reduce, finalize=nil, deprecated=nil) def group(key, condition, initial, reduce, finalize=nil)
# Warn of changed API post eval deprecation.
if finalize == true || finalize == false || deprecated
warn "The API for Collection#group has changed. 'Finalize' is now the fifth parameter, " +
"since it's no longer necessary to specify whether #group is run as a command. " +
"See http://api.mongodb.org/ruby/current/Mongo/Collection.html#group-instance_method for details."
end
reduce = BSON::Code.new(reduce) unless reduce.is_a?(BSON::Code) reduce = BSON::Code.new(reduce) unless reduce.is_a?(BSON::Code)
group_command = { group_command = {
@ -499,9 +489,6 @@ module Mongo
group_command["group"][key_type] = key_value group_command["group"][key_type] = key_value
end end
# only add finalize if specified
# check to see if users have sent the finalizer as the last argument.
finalize = deprecated if deprecated.is_a?(String) || deprecated.is_a?(BSON::Code)
finalize = BSON::Code.new(finalize) if finalize.is_a?(String) finalize = BSON::Code.new(finalize) if finalize.is_a?(String)
if finalize.is_a?(BSON::Code) if finalize.is_a?(BSON::Code)
group_command['group']['finalize'] = finalize group_command['group']['finalize'] = finalize

View File

@ -545,7 +545,7 @@ class DBAPITest < Test::Unit::TestCase
assert_equal 1, test.group([], {"a" => {"$gt" => 1}}, {"count" => 0}, "function (obj, prev) { prev.count++; }")[0]["count"] assert_equal 1, test.group([], {"a" => {"$gt" => 1}}, {"count" => 0}, "function (obj, prev) { prev.count++; }")[0]["count"]
finalize = "function (obj) { obj.f = obj.count - 1; }" finalize = "function (obj) { obj.f = obj.count - 1; }"
assert_equal 2, test.group([], {}, {"count" => 0}, "function (obj, prev) { prev.count++; }", true, finalize)[0]["f"] assert_equal 2, test.group([], {}, {"count" => 0}, "function (obj, prev) { prev.count++; }", finalize)[0]["f"]
test.insert("a" => 2, "b" => 3) test.insert("a" => 2, "b" => 3)
expected = [{"a" => 2, "count" => 2}, expected = [{"a" => 2, "count" => 2},