module Mongoid::Clients::Options
def clear_persistence_context(original_cluster = nil, context = nil)
def clear_persistence_context(original_cluster = nil, context = nil) PersistenceContext.clear(self, original_cluster, context) end
def collection(parent = nil)
def collection(parent = nil) persistence_context.collection(parent) end
def collection_name
def collection_name persistence_context.collection_name end
def mongo_client
def mongo_client persistence_context.client end
def persistence_context
def persistence_context PersistenceContext.get(self) || PersistenceContext.get(self.class) || PersistenceContext.new(self.class) end
def persistence_context?
def persistence_context? !!(PersistenceContext.get(self) || PersistenceContext.get(self.class)) end
def set_persistence_context(options_or_context)
def set_persistence_context(options_or_context) PersistenceContext.set(self, options_or_context) end
def with(options_or_context, &block)
(**options)-
:client(String | Symbol) -- The client name. -
:database(String | Symbol) -- The database name. -
:collection(String | Symbol) -- The collection name.
Parameters:
-
options_or_context(Hash | Mongoid::PersistenceContext) --
Other tags:
- Example: Save the current document to a different collection. -
def with(options_or_context, &block) original_context = PersistenceContext.get(self) original_cluster = persistence_context.cluster set_persistence_context(options_or_context) yield self ensure clear_persistence_context(original_cluster, original_context) end