Module: Mongoid::MultiDatabase::ClassMethods

Defined in:
lib/mongoid/multi_database.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#databaseMongo::DB

Gets the database from the class.

Examples:

Get the database.

Model.database

Returns:

  • (Mongo::DB)

    The database.



16
# File 'lib/mongoid/multi_database.rb', line 16

def database; @database end

#inherited(subclass) ⇒ Object



30
31
32
33
# File 'lib/mongoid/multi_database.rb', line 30

def inherited(subclass)
  super
  subclass.set_database(database.dup) if database
end

#set_database(name) ⇒ String

Set the database name.

Examples:

Set the database name.

Model.set_database(:testing)

Parameters:

  • name (Symbol)

    The database name.

Returns:

  • (String)

    The database name.



26
27
28
# File 'lib/mongoid/multi_database.rb', line 26

def set_database(name)
  @database = name.to_s
end