Module: Mongoid::Clients::Options::ClassMethods
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Extended In:
| |
Defined in: | lib/mongoid/clients/options.rb |
Instance Method Summary
-
#client_name ⇒ String
Get the database client name for the current persistence context of the document class.
-
#collection ⇒ Mongo::Collection
Get the collection for the current persistence context of the document class.
-
#collection_name ⇒ String
Get the collection name for the current persistence context of the document class.
-
#database_name ⇒ String
Get the database name for the current persistence context of the document class.
-
#mongo_client ⇒ Mongo::Client
Get the client for the current persistence context of the document class.
-
#persistence_context ⇒ Mongoid::PersistenceContent
Get the current persistence context of the document class.
-
#with(options, &block)
Change the persistence context for this class during the block.
Instance Method Details
#client_name ⇒ String
Get the database client name for the current persistence context of the document class.
# File 'lib/mongoid/clients/options.rb', line 146
def client_name persistence_context.client_name end
#collection ⇒ Mongo::Collection
Get the collection for the current persistence context of the document class.
# File 'lib/mongoid/clients/options.rb', line 182
def collection persistence_context.collection end
#collection_name ⇒ String
Get the collection name for the current persistence context of the document class.
# File 'lib/mongoid/clients/options.rb', line 158
def collection_name persistence_context.collection_name end
#database_name ⇒ String
Get the database name for the current persistence context of the document class.
# File 'lib/mongoid/clients/options.rb', line 170
def database_name persistence_context.database_name end
#mongo_client ⇒ Mongo::Client
Get the client for the current persistence context of the document class.
# File 'lib/mongoid/clients/options.rb', line 194
def mongo_client persistence_context.client end
#persistence_context ⇒ Mongoid::PersistenceContent
Get the current persistence context of the document class. If a persistence context is not set, a new one will be initialized and returned.
# File 'lib/mongoid/clients/options.rb', line 228
def persistence_context PersistenceContext.get(self) || PersistenceContext.new(self) end
#with(options, &block)
Change the persistence context for this class during the block.
# File 'lib/mongoid/clients/options.rb', line 210
def with(, &block) original_context = PersistenceContext.get(self) original_cluster = persistence_context.cluster PersistenceContext.set(self, ) yield self ensure PersistenceContext.clear(self, original_cluster, original_context) end