Module: Mongoid::Sessions
- Extended by:
- ActiveSupport::Concern
- Included in:
- Components
- Defined in:
- lib/mongoid/sessions.rb,
lib/mongoid/sessions/factory.rb,
lib/mongoid/sessions/mongo_uri.rb,
lib/mongoid/sessions/validators/storage.rb
Defined Under Namespace
Modules: ClassMethods, Factory, Validators Classes: MongoUri
Class Method Summary collapse
-
.clear ⇒ Array
Clear all sessions from the current thread.
-
.default ⇒ Moped::Session
Get the default session.
-
.disconnect ⇒ true
Disconnect all active sessions.
-
.with_name(name) ⇒ Moped::Session
Get a session with the provided name.
Instance Method Summary collapse
-
#collection ⇒ Moped::Collection
Get the collection for this model from the session.
-
#collection_name ⇒ String
Get the name of the collection this model persists to.
-
#mongo_session ⇒ Moped::Session
Get the session for this model.
-
#with(options) ⇒ Document
Tell the next persistance operation to store in a specific collection, database or session.
Class Method Details
.clear ⇒ Array
Clear all sessions from the current thread.
96 97 98 |
# File 'lib/mongoid/sessions.rb', line 96 def clear Threaded.sessions.clear end |
.default ⇒ Moped::Session
Get the default session.
108 109 110 |
# File 'lib/mongoid/sessions.rb', line 108 def default Threaded.sessions[:default] ||= Sessions::Factory.default end |
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.
24 25 26 |
# File 'lib/mongoid/sessions.rb', line 24 def collection self.class.collection end |
#collection_name ⇒ String
Get the name of the collection this model persists to. This will be either the pluralized class name or the option defined in the store_in macro.
38 39 40 |
# File 'lib/mongoid/sessions.rb', line 38 def collection_name self.class.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
53 54 55 |
# File 'lib/mongoid/sessions.rb', line 53 def mongo_session self.class.mongo_session end |