Module: Mongoid::Clients::ClassMethods
- Extended by:
- Gem::Deprecate
- Defined in:
- lib/mongoid/clients.rb
Instance Method Summary collapse
-
#collection ⇒ Mongo::Collection
Get the collection for this model from the client.
-
#mongo_client ⇒ Mongo::Client
(also: #mongo_session)
Get the client for this model.
Instance Method Details
#collection ⇒ Mongo::Collection
Get the collection for this model from the client. Will check for an overridden collection name from the store_in macro or the collection with a pluralized model name.
137 138 139 |
# File 'lib/mongoid/clients.rb', line 137 def collection mongo_client[collection_name] end |
#mongo_client ⇒ Mongo::Client Also known as: mongo_session
Get the client for this model. This is determined in the following order:
1. Any custom configuration provided by the 'store_in' macro.
2. The 'default' client as provided in the mongoid.yml
117 118 119 120 121 122 123 |
# File 'lib/mongoid/clients.rb', line 117 def mongo_client name = client_name client = Clients.with_name(name) client = client.use(database_name) client = client.with(self.) Clients.set(name, client) end |