Module: MongoMapper

Defined in:
lib/mongo_mapper_ext/mongo_mapper/plugins/db_config.rb

Defined Under Namespace

Modules: Migration Classes: ConnectionsPool, DatabasesPool

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.db_configObject

Returns the value of attribute db_config.



45
46
47
# File 'lib/mongo_mapper_ext/mongo_mapper/plugins/db_config.rb', line 45

def db_config
  @db_config
end

Class Method Details

.connectionsObject



51
52
53
# File 'lib/mongo_mapper_ext/mongo_mapper/plugins/db_config.rb', line 51

def connections
  @connections ||= ConnectionsPool.new
end

.databasesObject



55
56
57
# File 'lib/mongo_mapper_ext/mongo_mapper/plugins/db_config.rb', line 55

def databases
  @databases ||= DatabasesPool.new
end

.use_database(database_alias) ⇒ Object



59
60
61
62
63
64
# File 'lib/mongo_mapper_ext/mongo_mapper/plugins/db_config.rb', line 59

def use_database database_alias
  database_alias = database_alias.to_s
  raise "unknown database alias :#{database_alias}" unless MongoMapper.db_config.include? database_alias
  MongoMapper.connection = MongoMapper.connections[database_alias]
  MongoMapper.database = MongoMapper.db_config[database_alias]['name']
end