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.
131 132 133 |
# File 'lib/mongoid/clients/options.rb', line 131 def client_name persistence_context.client_name end |
#collection ⇒ Mongo::Collection
Get the collection for the current persistence context of the document class.
167 168 169 |
# File 'lib/mongoid/clients/options.rb', line 167 def collection persistence_context.collection end |
#collection_name ⇒ String
Get the collection name for the current persistence context of the document class.
143 144 145 |
# File 'lib/mongoid/clients/options.rb', line 143 def collection_name persistence_context.collection_name end |
#database_name ⇒ String
Get the database name for the current persistence context of the document class.
155 156 157 |
# File 'lib/mongoid/clients/options.rb', line 155 def database_name persistence_context.database_name end |
#mongo_client ⇒ Mongo::Client
Get the client for the current persistence context of the document class.
179 180 181 |
# File 'lib/mongoid/clients/options.rb', line 179 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.
213 214 215 |
# File 'lib/mongoid/clients/options.rb', line 213 def persistence_context PersistenceContext.get(self) || PersistenceContext.new(self) end |
#with(options, &block) ⇒ Object
Change the persistence context for this class during the block.
195 196 197 198 199 200 201 202 |
# File 'lib/mongoid/clients/options.rb', line 195 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 |