Methods

Class/Module Index [+]

Quicksearch

Mongoid::Sessions::Factory

Public Instance Methods

create(name = nil) click to toggle source

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.

@example Create the session.

Factory.create(:secondary)

@param [ String, Symbol ] name The named session configuration.

@raise [ Errors::NoSessionConfig ] If no config could be found.

@return [ Moped::Session ] The new session.

@since 3.0.0

# File lib/mongoid/sessions/factory.rb, line 23
def create(name = nil)
  return default unless name
  config = Mongoid.sessions[name]
  raise Errors::NoSessionConfig.new(name) unless config
  create_session(config)
end
default() click to toggle source

Get the default session.

@example Get the default session.

Factory.default

@raise [ Errors::NoSessionConfig ] If no default configuration is

found.

@return [ Moped::Session ] The default session.

@since 3.0.0

# File lib/mongoid/sessions/factory.rb, line 41
def default
  create_session(Mongoid.sessions[:default])
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.