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
30 31 32 |
# File 'lib/mongoid/clients/options.rb', line 30 def collection(parent = nil) persistence_context.collection(parent) end |
#collection_name ⇒ Object
34 35 36 |
# File 'lib/mongoid/clients/options.rb', line 34 def collection_name persistence_context.collection_name end |
#mongo_client ⇒ Object
38 39 40 |
# File 'lib/mongoid/clients/options.rb', line 38 def mongo_client persistence_context.client end |
#persistence_context ⇒ Object
42 43 44 45 46 |
# File 'lib/mongoid/clients/options.rb', line 42 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 |
# File 'lib/mongoid/clients/options.rb', line 22 def with(, &block) original_cluster = persistence_context.cluster set_persistence_context() yield self ensure clear_persistence_context(original_cluster) end |