Module: Mongoid::Sessions::ClassMethods
- Defined in:
- lib/mongoid/sessions.rb
Instance Method Summary collapse
-
#collection ⇒ Moped::Collection
Get the collection for this model from the session.
-
#mongo_session ⇒ Moped::Session
Get the session for this model.
Instance Method Details
#collection ⇒ Moped::Collection
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.
120 121 122 |
# File 'lib/mongoid/sessions.rb', line 120 def collection mongo_session[collection_name] end |
#mongo_session ⇒ Moped::Session
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
104 105 106 107 108 |
# File 'lib/mongoid/sessions.rb', line 104 def mongo_session session = Sessions.with_name(session_name) session.use(database_name) self. ? session.with(self.) : session end |