Don't modify hash arguments.
This commit is contained in:
parent
9cc6bad613
commit
8887402ca8
@ -172,6 +172,7 @@ module Mongo
|
||||
#
|
||||
# @core find find-instance_method
|
||||
def find(selector={}, opts={})
|
||||
opts = opts.dup
|
||||
fields = opts.delete(:fields)
|
||||
fields = ["_id"] if fields && fields.empty?
|
||||
skip = opts.delete(:skip) || skip || 0
|
||||
@ -437,8 +438,9 @@ module Mongo
|
||||
#
|
||||
# @core indexes create_index-instance_method
|
||||
def create_index(spec, opts={})
|
||||
opts[:dropDups] = opts.delete(:drop_dups) if opts[:drop_dups]
|
||||
opts[:dropDups] = opts[:drop_dups] if opts[:drop_dups]
|
||||
field_spec = parse_index_spec(spec)
|
||||
opts = opts.dup
|
||||
name = opts.delete(:name) || generate_index_name(field_spec)
|
||||
name = name.to_s if name
|
||||
|
||||
@ -466,7 +468,7 @@ module Mongo
|
||||
now = Time.now.utc.to_i
|
||||
field_spec = parse_index_spec(spec)
|
||||
|
||||
name = opts.delete(:name) || generate_index_name(field_spec)
|
||||
name = opts[:name] || generate_index_name(field_spec)
|
||||
name = name.to_s if name
|
||||
|
||||
if !@cache[name] || @cache[name] <= now
|
||||
@ -559,7 +561,7 @@ module Mongo
|
||||
def map_reduce(map, reduce, opts={})
|
||||
map = BSON::Code.new(map) unless map.is_a?(BSON::Code)
|
||||
reduce = BSON::Code.new(reduce) unless reduce.is_a?(BSON::Code)
|
||||
raw = opts.delete(:raw)
|
||||
raw = opts[:raw]
|
||||
|
||||
hash = BSON::OrderedHash.new
|
||||
hash['mapreduce'] = self.name
|
||||
|
@ -65,7 +65,7 @@ module Mongo
|
||||
#
|
||||
# @return [Mongo::ObjectId] the file's id.
|
||||
def put(data, opts={})
|
||||
filename = opts.delete :filename
|
||||
filename = opts[:filename]
|
||||
opts.merge!(default_grid_io_opts)
|
||||
file = GridIO.new(@files, @chunks, filename, 'w', opts=opts)
|
||||
file.write(data)
|
||||
|
@ -93,6 +93,7 @@ module Mongo
|
||||
#
|
||||
# @return [Mongo::GridIO]
|
||||
def open(filename, mode, opts={})
|
||||
opts = opts.dup
|
||||
opts.merge!(default_grid_io_opts(filename))
|
||||
del = opts.delete(:delete_old) && mode == 'w'
|
||||
file = GridIO.new(@files, @chunks, filename, mode, opts)
|
||||
|
@ -55,6 +55,7 @@ module Mongo
|
||||
@chunks = chunks
|
||||
@filename = filename
|
||||
@mode = mode
|
||||
opts = opts.dup
|
||||
@query = opts.delete(:query) || {}
|
||||
@query_opts = opts.delete(:query_opts) || {}
|
||||
@fs_name = opts.delete(:fs_name) || Grid::DEFAULT_FS_NAME
|
||||
@ -410,6 +411,7 @@ module Mongo
|
||||
|
||||
# Initialize the class for writing a file.
|
||||
def init_write(opts)
|
||||
opts = opts.dup
|
||||
@files_id = opts.delete(:_id) || BSON::ObjectId.new
|
||||
@content_type = opts.delete(:content_type) || (defined? MIME) && get_content_type || DEFAULT_CONTENT_TYPE
|
||||
@chunk_size = opts.delete(:chunk_size) || DEFAULT_CHUNK_SIZE
|
||||
|
Loading…
Reference in New Issue
Block a user