Module: Mongoid::Clients::Options
- Extended by:
- ActiveSupport::Concern
- Included in:
- Mongoid::Clients, Mongoid::Criteria
- Defined in:
- lib/mongoid/clients/options.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #collection(parent = nil) ⇒ Object
- #collection_name ⇒ Object
- #mongo_client ⇒ Object
- #persistence_context ⇒ Object
-
#with(options_or_context, &block) ⇒ Object
Change the persistence context for this object during the block.
Instance Method Details
#collection(parent = nil) ⇒ Object
31 32 33 |
# File 'lib/mongoid/clients/options.rb', line 31 def collection(parent = nil) persistence_context.collection(parent) end |
#collection_name ⇒ Object
35 36 37 |
# File 'lib/mongoid/clients/options.rb', line 35 def collection_name persistence_context.collection_name end |
#mongo_client ⇒ Object
39 40 41 |
# File 'lib/mongoid/clients/options.rb', line 39 def mongo_client persistence_context.client end |
#persistence_context ⇒ Object
43 44 45 46 47 |
# File 'lib/mongoid/clients/options.rb', line 43 def persistence_context PersistenceContext.get(self) || PersistenceContext.get(self.class) || PersistenceContext.new(self.class) end |
#with(options_or_context, &block) ⇒ Object
Change the persistence context for this object during the block.
22 23 24 25 26 27 28 29 |
# File 'lib/mongoid/clients/options.rb', line 22 def with(, &block) original_context = PersistenceContext.get(self) original_cluster = persistence_context.cluster set_persistence_context() yield self ensure clear_persistence_context(original_cluster, original_context) end |