Module: Mongoid::Sessions::Factory
Instance Method Summary collapse
-
#create(name = nil) ⇒ Moped::Session
Create a new session given the named configuration.
-
#default ⇒ Moped::Session
Get the default session.
Instance Method Details
#create(name = nil) ⇒ Moped::Session
Create a new session given the named configuration. If no name is provided, return a new session with the default configuration. If a name is provided for which no configuration exists, an error will be raised.
24 25 26 27 28 29 |
# File 'lib/mongoid/sessions/factory.rb', line 24 def create(name = nil) return default unless name config = Mongoid.sessions[name] raise Errors::NoSessionConfig.new(name) unless config create_session(config) end |
#default ⇒ Moped::Session
Get the default session.
42 43 44 |
# File 'lib/mongoid/sessions/factory.rb', line 42 def default create_session(Mongoid.sessions[:default]) end |