Module: EmeraldODM::Connector
- Defined in:
- lib/emerald_odm.rb
Class Method Summary collapse
-
.database(db_name) ⇒ Mongo::Client
The database client.
- .databases_instances ⇒ Object
Class Method Details
.database(db_name) ⇒ Mongo::Client
Returns The database client.
13 14 15 16 17 18 19 20 |
# File 'lib/emerald_odm.rb', line 13 def self.database(db_name) if databases_instances[db_name].nil? db_settings = EmeraldODM.databases_settings[db_name] raise Exceptions::MissingDatabaseSettings.new("Database settings not found for #{db_name}") if db_settings.nil? || db_settings.empty? self.databases_instances[db_name] = Mongo::Client.new(*db_settings) end databases_instances[db_name] end |
.databases_instances ⇒ Object
22 23 24 |
# File 'lib/emerald_odm.rb', line 22 def self.databases_instances @databases_instances ||= {} end |