Class: MongoMapper::DatabasesPool

Inherits:
Hash
  • Object
show all
Defined in:
lib/mongo_mapper_ext/db_config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mongo_mapper) ⇒ DatabasesPool

Returns a new instance of DatabasesPool.



29
30
31
# File 'lib/mongo_mapper_ext/db_config.rb', line 29

def initialize mongo_mapper
  self.mongo_mapper = mongo_mapper
end

Instance Attribute Details

#mongo_mapperObject

Returns the value of attribute mongo_mapper.



28
29
30
# File 'lib/mongo_mapper_ext/db_config.rb', line 28

def mongo_mapper
  @mongo_mapper
end

Instance Method Details

#[](database_alias) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'lib/mongo_mapper_ext/db_config.rb', line 33

def [](database_alias)
  database_alias = database_alias.to_s
  unless db = super(database_alias)
    mongo_mapper.db_config.should! :include, database_alias
    db_options = mongo_mapper.db_config[database_alias]
    db = mongo_mapper.connections[database_alias].db db_options['name'].should!(:be_a, String)
    self[database_alias] = db
  end
  return db
end