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
33 34 35 |
# File 'lib/mongoid/clients/options.rb', line 33 def collection(parent = nil) persistence_context.collection(parent) end |
#collection_name ⇒ Object
37 38 39 |
# File 'lib/mongoid/clients/options.rb', line 37 def collection_name persistence_context.collection_name end |
#mongo_client ⇒ Object
41 42 43 |
# File 'lib/mongoid/clients/options.rb', line 41 def mongo_client persistence_context.client end |
#persistence_context ⇒ Object
45 46 47 48 49 |
# File 'lib/mongoid/clients/options.rb', line 45 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.
24 25 26 27 28 29 30 31 |
# File 'lib/mongoid/clients/options.rb', line 24 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 |