Module: Mongoid::Clients::Factory
Overview
Factory used to create database clients.
Instance Method Summary collapse
-
#create(name = nil) ⇒ Mongo::Client
Create a new client given the named configuration.
-
#default ⇒ Mongo::Client
Get the default client.
Methods included from Loggable
Instance Method Details
#create(name = nil) ⇒ Mongo::Client
Create a new client given the named configuration. If no name is provided, return a new client with the default configuration. If a name is provided for which no configuration exists, an error will be raised.
25 26 27 28 29 30 |
# File 'lib/mongoid/clients/factory.rb', line 25 def create(name = nil) return default unless name config = Mongoid.clients[name] raise Errors::NoClientConfig.new(name) unless config create_client(config) end |
#default ⇒ Mongo::Client
Get the default client.
41 42 43 |
# File 'lib/mongoid/clients/factory.rb', line 41 def default create_client(Mongoid.clients[:default]) end |