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.
146 147 148 |
# 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.
182 183 184 |
# 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.
158 159 160 |
# 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.
170 171 172 |
# 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.
194 195 196 |
# 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.
228 229 230 |
# File 'lib/mongoid/clients/options.rb', line 228 def persistence_context PersistenceContext.get(self) || PersistenceContext.new(self) end |
#with(options, &block) ⇒ Object
Change the persistence context for this class during the block.
210 211 212 213 214 215 216 217 |
# 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 |