From e55136e05697aec9e53b66cbe2dbfe4e8a6c68b4 Mon Sep 17 00:00:00 2001 From: Kyle Banker Date: Tue, 4 Jan 2011 18:08:29 -0500 Subject: [PATCH] minor: doc and Collection#update clarification --- lib/mongo/collection.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/mongo/collection.rb b/lib/mongo/collection.rb index 18b0385f3f..259a486656 100644 --- a/lib/mongo/collection.rb +++ b/lib/mongo/collection.rb @@ -336,8 +336,8 @@ def remove(selector={}, opts={}) # a hash specifying the fields to be changed in the selected document, # or (in the case of an upsert) the document to be inserted # - # @option [Boolean] :upsert (+false+) if true, performs an upsert (update or insert) - # @option [Boolean] :multi (+false+) update all documents matching the selector, as opposed to + # @option opts [Boolean] :upsert (+false+) if true, performs an upsert (update or insert) + # @option opts [Boolean] :multi (+false+) update all documents matching the selector, as opposed to # just the first matching document. Note: only works in MongoDB 1.1.3 or later. # @option opts [Boolean] :safe (+false+) # If true, check that the save succeeded. OperationFailure @@ -350,14 +350,14 @@ def remove(selector={}, opts={}) # Otherwise, returns true. # # @core update update-instance_method - def update(selector, document, options={}) + def update(selector, document, opts={}) # Initial byte is 0. - safe = options.has_key?(:safe) ? options[:safe] : @safe + safe = opts.fetch(:safe, @safe) message = BSON::ByteBuffer.new("\0\0\0\0") BSON::BSON_RUBY.serialize_cstr(message, "#{@db.name}.#{@name}") update_options = 0 - update_options += 1 if options[:upsert] - update_options += 2 if options[:multi] + update_options += 1 if opts[:upsert] + update_options += 2 if opts[:multi] message.put_int(update_options) message.put_binary(BSON::BSON_CODER.serialize(selector, false, true).to_s) message.put_binary(BSON::BSON_CODER.serialize(document, false, true).to_s)