Module: Mongoid::Sessions
- Extended by:
- ActiveSupport::Concern
- Includes:
- Options, StorageOptions, ThreadOptions
- Included in:
- Composable
- Defined in:
- lib/mongoid/sessions.rb,
lib/mongoid/sessions/factory.rb,
lib/mongoid/sessions/options.rb,
lib/mongoid/sessions/mongo_uri.rb,
lib/mongoid/sessions/thread_options.rb,
lib/mongoid/sessions/storage_options.rb,
lib/mongoid/sessions/validators/storage.rb
Defined Under Namespace
Modules: ClassMethods, Factory, Options, StorageOptions, ThreadOptions, 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 ⇒ Object
- #mongo_session ⇒ Object
Methods included from Options
Class Method Details
.clear ⇒ Array
Clear all sessions from the current thread.
24 25 26 |
# File 'lib/mongoid/sessions.rb', line 24 def clear Threaded.sessions.clear end |
.default ⇒ Moped::Session
Get the default session.
36 37 38 |
# File 'lib/mongoid/sessions.rb', line 36 def default Threaded.sessions[:default] ||= Sessions::Factory.default end |
.disconnect ⇒ true
Disconnect all active sessions.
48 49 50 51 52 |
# File 'lib/mongoid/sessions.rb', line 48 def disconnect Threaded.sessions.values.each do |session| session.disconnect end 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.
79 80 81 |
# File 'lib/mongoid/sessions.rb', line 79 def collection mongo_session[collection_name] end |
#collection_name ⇒ Object
87 88 89 |
# File 'lib/mongoid/sessions.rb', line 87 def collection_name super || self.class.collection_name end |
#mongo_session ⇒ Object
83 84 85 |
# File 'lib/mongoid/sessions.rb', line 83 def mongo_session super || self.class.mongo_session end |