Module: Mongoid::Clients::Options::ClassMethods
- Defined in:
- lib/mongoid/clients/options.rb
Instance Method Summary collapse
-
#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) ⇒ Object
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.
133 134 135 |
# File 'lib/mongoid/clients/options.rb', line 133 def client_name persistence_context.client_name end |
#collection ⇒ Mongo::Collection
Get the collection for the current persistence context of the document class.
169 170 171 |
# File 'lib/mongoid/clients/options.rb', line 169 def collection persistence_context.collection end |
#collection_name ⇒ String
Get the collection name for the current persistence context of the document class.
145 146 147 |
# File 'lib/mongoid/clients/options.rb', line 145 def collection_name persistence_context.collection_name end |
#database_name ⇒ String
Get the database name for the current persistence context of the document class.
157 158 159 |
# File 'lib/mongoid/clients/options.rb', line 157 def database_name persistence_context.database_name end |
#mongo_client ⇒ Mongo::Client
Get the client for the current persistence context of the document class.
181 182 183 |
# File 'lib/mongoid/clients/options.rb', line 181 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.
215 216 217 |
# File 'lib/mongoid/clients/options.rb', line 215 def persistence_context PersistenceContext.get(self) || PersistenceContext.new(self) end |
#with(options, &block) ⇒ Object
Change the persistence context for this class during the block.
197 198 199 200 201 202 203 204 |
# File 'lib/mongoid/clients/options.rb', line 197 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 |