From 459381b9e40d983e64ddabab46c6f3d2b84697f3 Mon Sep 17 00:00:00 2001 From: Jim Menard Date: Wed, 17 Dec 2008 13:14:42 -0500 Subject: [PATCH] Guard against nil options in DB#create_collection. Doc fix. --- lib/mongo/db.rb | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/mongo/db.rb b/lib/mongo/db.rb index 40332d1..079690e 100644 --- a/lib/mongo/db.rb +++ b/lib/mongo/db.rb @@ -83,6 +83,16 @@ module XGen # Create a collection. If +strict+ is false, will return existing or # new collection. If +strict+ is true, will raise an error if # collection +name+ already exists. + # + # Options is an optional hash: + # + # :capped :: Boolean. If not specified, capped is +false+. + # + # :size :: If +capped+ is +true+, specifies the maximum number of + # bytes. If +false+, specifies the initial extent of the + # collection. + # + # :max :: Max number of records in a capped collection. Optional. def create_collection(name, options={}) # First check existence if collection_names.include?(full_coll_name(name)) @@ -96,7 +106,7 @@ module XGen # Create new collection oh = OrderedHash.new oh[:create] = name - doc = db_command(oh.merge(options)) + doc = db_command(oh.merge(options || {})) ok = doc['ok'] return Collection.new(self, name) if ok.kind_of?(Numeric) && (ok.to_i == 1 || ok.to_i == 0) raise "Error creating collection: #{doc.inspect}" @@ -111,16 +121,6 @@ module XGen # Return a collection. If +strict+ is false, will return existing or # new collection. If +strict+ is true, will raise an error if # collection +name+ does not already exists. - # - # Options: - # - # :capped :: Boolean. If not specified, capped is +false+. - # - # :size :: If +capped+ is +true+, specifies the maximum number of - # bytes. If +false+, specifies the initial extent of the - # collection. - # - # :max :: Max number of records in a capped collection. Optional. def collection(name) return Collection.new(self, name) if collection_names.include?(full_coll_name(name)) if strict?