@@ -56,7 +56,7 @@ def strict?; @strict; end
5656
5757 # Instances of DB are normally obtained by calling Mongo#db.
5858 #
59- # @param [String] db_name the database name.
59+ # @param [String] name the database name.
6060 # @param [Mongo::Connection] connection a connection object pointing to MongoDB. Note
6161 # that databases are usually instantiated via the Connection class. See the examples below.
6262 #
@@ -76,8 +76,8 @@ def strict?; @strict; end
7676 # @option options [Integer] :cache_time (300) Set the time that all ensure_index calls should cache the command.
7777 #
7878 # @core databases constructor_details
79- def initialize ( db_name , connection , options = { } )
80- @name = Mongo ::Support . validate_db_name ( db_name )
79+ def initialize ( name , connection , options = { } )
80+ @name = Mongo ::Support . validate_db_name ( name )
8181 @connection = connection
8282 @strict = options [ :strict ]
8383 @pk_factory = options [ :pk ]
@@ -208,8 +208,8 @@ def collection_names
208208 #
209209 # @return [Array<Mongo::Collection>]
210210 def collections
211- collection_names . map do |collection_name |
212- Collection . new ( self , collection_name )
211+ collection_names . map do |name |
212+ Collection . new ( name , self )
213213 end
214214 end
215215
@@ -223,7 +223,7 @@ def collections
223223 def collections_info ( coll_name = nil )
224224 selector = { }
225225 selector [ :name ] = full_collection_name ( coll_name ) if coll_name
226- Cursor . new ( Collection . new ( self , SYSTEM_NAMESPACE_COLLECTION ) , :selector => selector )
226+ Cursor . new ( Collection . new ( SYSTEM_NAMESPACE_COLLECTION , self ) , :selector => selector )
227227 end
228228
229229 # Create a collection.
@@ -252,15 +252,15 @@ def create_collection(name, options={})
252252 if strict?
253253 raise MongoDBError , "Collection #{ name } already exists. Currently in strict mode."
254254 else
255- return Collection . new ( self , name )
255+ return Collection . new ( name , self )
256256 end
257257 end
258258
259259 # Create a new collection.
260260 oh = BSON ::OrderedHash . new
261261 oh [ :create ] = name
262262 doc = command ( oh . merge ( options || { } ) )
263- return Collection . new ( self , name , :pk => @pk_factory ) if ok? ( doc )
263+ return Collection . new ( name , self , :pk => @pk_factory ) if ok? ( doc )
264264 raise MongoDBError , "Error creating collection: #{ doc . inspect } "
265265 end
266266
@@ -278,7 +278,7 @@ def collection(name, options={})
278278 else
279279 options [ :safe ] = options . fetch ( :safe , @safe )
280280 options . merge! ( :pk => @pk_factory ) unless options [ :pk ]
281- Collection . new ( self , name , options )
281+ Collection . new ( name , self , options )
282282 end
283283 end
284284 alias_method :[] , :collection
@@ -418,7 +418,7 @@ def drop_index(collection_name, index_name)
418418 def index_information ( collection_name )
419419 sel = { :ns => full_collection_name ( collection_name ) }
420420 info = { }
421- Cursor . new ( Collection . new ( self , SYSTEM_INDEX_COLLECTION ) , :selector => sel ) . each do |index |
421+ Cursor . new ( Collection . new ( SYSTEM_INDEX_COLLECTION , self ) , :selector => sel ) . each do |index |
422422 info [ index [ 'name' ] ] = index
423423 end
424424 info
@@ -558,7 +558,7 @@ def profiling_level=(level)
558558 #
559559 # @return [Array] a list of documents containing profiling information.
560560 def profiling_info
561- Cursor . new ( Collection . new ( self , DB :: SYSTEM_PROFILE_COLLECTION ) , :selector => { } ) . to_a
561+ Cursor . new ( Collection . new ( SYSTEM_PROFILE_COLLECTION , self ) , :selector => { } ) . to_a
562562 end
563563
564564 # Validate a named collection.
@@ -581,7 +581,7 @@ def validate_collection(name)
581581 private
582582
583583 def system_command_collection
584- Collection . new ( self , SYSTEM_COMMAND_COLLECTION )
584+ Collection . new ( SYSTEM_COMMAND_COLLECTION , self )
585585 end
586586 end
587587end
0 commit comments