Module: Mongoid::Clients::Options
- Extended by:
- ActiveSupport::Concern, Gem::Deprecate
- Included in:
- Mongoid::Clients, Mongoid::Criteria
- Defined in:
- lib/mongoid/clients/options.rb
Defined Under Namespace
Modules: ClassMethods, Threaded Classes: Proxy
Instance Method Summary collapse
- #collection_name ⇒ Object
- #mongo_client ⇒ Object (also: #mongo_session)
- #persistence_options ⇒ Object
-
#with(options) ⇒ Document
Tell the next persistance operation to store in a specific collection, database or client.
Instance Method Details
#collection_name ⇒ Object
60 61 62 63 64 |
# File 'lib/mongoid/clients/options.rb', line 60 def collection_name if && v = [:collection] return v.to_sym end end |
#mongo_client ⇒ Object Also known as: mongo_session
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/mongoid/clients/options.rb', line 46 def mongo_client if if [:client] client = Clients.with_name([:client]) else client = Clients.with_name(self.class.client_name) client.use(self.class.database_name) end client.with(.reject{ |k, v| k == :collection || k == :client }) end end |
#persistence_options ⇒ Object
42 43 44 |
# File 'lib/mongoid/clients/options.rb', line 42 def @persistence_options end |
#with(options) ⇒ Document
Note:
This method will instantiate a new client under the covers and can be expensive. It is also recommended that the user manually closes the extra client after using it, otherwise an excessive amount of connections to the server will be eventually opened.
Tell the next persistance operation to store in a specific collection, database or client.
37 38 39 40 |
# File 'lib/mongoid/clients/options.rb', line 37 def with() @persistence_options = self end |