module Mongoid::Sessions::ClassMethods
Public Instance Methods
collection()
click to toggle source
Get the collection for this model from the session. Will check for an overridden collection name from the store_in macro or the collection with a pluralized model name.
@example Get the model's collection.
Model.collection
@return [ Moped::Collection ] The collection.
@since 3.0.0
# File lib/mongoid/sessions.rb, line 119 def collection mongo_session[collection_name] end
mongo_session()
click to toggle source
Get the session for this model. This is determined in the following order:
1. Any custom configuration provided by the 'store_in' macro. 2. The 'default' session as provided in the mongoid.yml
@example Get the session.
Model.mongo_session
@return [ Moped::Session ] The default moped session.
@since 3.0.0
# File lib/mongoid/sessions.rb, line 103 def mongo_session session = Sessions.with_name(session_name) session.use(database_name) self.persistence_options ? session.with(self.persistence_options) : session end