Method: MongoMapper::Document::ClassMethods#database

Defined in:
lib/mongo_mapper/document.rb

#databaseMongo::DB

Returns the database the document should use. Defaults to

MongoMapper.database if other database is not set.

Returns:

  • (Mongo::DB)

    the mongo database instance



274
275
276
277
278
279
280
# File 'lib/mongo_mapper/document.rb', line 274

def database
  if database_name.nil?
    MongoMapper.database
  else
    connection.db(database_name)
  end
end