Module: Mongoid::Clients::Options
- Extended by:
- ActiveSupport::Concern
- 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
- #persistence_options ⇒ Object
-
#with(options) ⇒ Document
Tell the next persistence operation to store in a specific collection, database or client.
Instance Method Details
#collection_name ⇒ Object
58 59 60 61 62 |
# File 'lib/mongoid/clients/options.rb', line 58 def collection_name if && v = [:collection] return v.to_sym end end |
#mongo_client ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/mongoid/clients/options.rb', line 45 def mongo_client tmp = if (opts = tmp && !tmp.empty? && tmp.dup) if opts[:client] client = Clients.with_name(opts[:client]) else client = Clients.with_name(self.class.client_name) client = client.use(self.class.database_name) end client.with(opts.reject{ |k, v| k == :collection || k == :client }) end end |
#persistence_options ⇒ Object
41 42 43 |
# File 'lib/mongoid/clients/options.rb', line 41 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 persistence operation to store in a specific collection, database or client.
36 37 38 39 |
# File 'lib/mongoid/clients/options.rb', line 36 def with() @persistence_options = self end |