Guard against nil options in DB#create_collection. Doc fix.
This commit is contained in:
parent
95e75995f6
commit
459381b9e4
@ -83,6 +83,16 @@ module XGen
|
|||||||
# Create a collection. If +strict+ is false, will return existing or
|
# Create a collection. If +strict+ is false, will return existing or
|
||||||
# new collection. If +strict+ is true, will raise an error if
|
# new collection. If +strict+ is true, will raise an error if
|
||||||
# collection +name+ already exists.
|
# 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={})
|
def create_collection(name, options={})
|
||||||
# First check existence
|
# First check existence
|
||||||
if collection_names.include?(full_coll_name(name))
|
if collection_names.include?(full_coll_name(name))
|
||||||
@ -96,7 +106,7 @@ module XGen
|
|||||||
# Create new collection
|
# Create new collection
|
||||||
oh = OrderedHash.new
|
oh = OrderedHash.new
|
||||||
oh[:create] = name
|
oh[:create] = name
|
||||||
doc = db_command(oh.merge(options))
|
doc = db_command(oh.merge(options || {}))
|
||||||
ok = doc['ok']
|
ok = doc['ok']
|
||||||
return Collection.new(self, name) if ok.kind_of?(Numeric) && (ok.to_i == 1 || ok.to_i == 0)
|
return Collection.new(self, name) if ok.kind_of?(Numeric) && (ok.to_i == 1 || ok.to_i == 0)
|
||||||
raise "Error creating collection: #{doc.inspect}"
|
raise "Error creating collection: #{doc.inspect}"
|
||||||
@ -111,16 +121,6 @@ module XGen
|
|||||||
# Return a collection. If +strict+ is false, will return existing or
|
# Return a collection. If +strict+ is false, will return existing or
|
||||||
# new collection. If +strict+ is true, will raise an error if
|
# new collection. If +strict+ is true, will raise an error if
|
||||||
# collection +name+ does not already exists.
|
# 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)
|
def collection(name)
|
||||||
return Collection.new(self, name) if collection_names.include?(full_coll_name(name))
|
return Collection.new(self, name) if collection_names.include?(full_coll_name(name))
|
||||||
if strict?
|
if strict?
|
||||||
|
Loading…
Reference in New Issue
Block a user