Module: Mongoid::Clients
- Extended by:
- ActiveSupport::Concern
- Includes:
- Options, StorageOptions
- Included in:
- Composable
- Defined in:
- build/mongoid-6.1/lib/mongoid/clients.rb,
build/mongoid-6.1/lib/mongoid/clients/factory.rb,
build/mongoid-6.1/lib/mongoid/clients/options.rb,
build/mongoid-6.1/lib/mongoid/clients/storage_options.rb,
build/mongoid-6.1/lib/mongoid/clients/validators/storage.rb
Defined Under Namespace
Modules: Factory, Options, StorageOptions, Validators
Class Method Summary collapse
-
.clear ⇒ Array
Clear all clients from the current thread.
- .clients ⇒ Object
-
.default ⇒ Mongo::Client
Get the default client.
-
.disconnect ⇒ true
Disconnect all active clients.
- .set(name, client) ⇒ Object
-
.with_name(name) ⇒ Mongo::Client
Get a client with the provided name.
Methods included from Options
#collection, #collection_name, #mongo_client, #persistence_context, #with
Class Method Details
.clear ⇒ Array
Clear all clients from the current thread.
23 24 25 |
# File 'build/mongoid-6.1/lib/mongoid/clients.rb', line 23 def clear clients.clear end |
.clients ⇒ Object
75 76 77 |
# File 'build/mongoid-6.1/lib/mongoid/clients.rb', line 75 def clients @clients ||= {} end |
.default ⇒ Mongo::Client
Get the default client.
35 36 37 |
# File 'build/mongoid-6.1/lib/mongoid/clients.rb', line 35 def default with_name(:default) end |
.disconnect ⇒ true
Disconnect all active clients.
47 48 49 50 51 |
# File 'build/mongoid-6.1/lib/mongoid/clients.rb', line 47 def disconnect clients.values.each do |client| client.close end end |
.set(name, client) ⇒ Object
71 72 73 |
# File 'build/mongoid-6.1/lib/mongoid/clients.rb', line 71 def set(name, client) clients[name.to_sym] = client end |
.with_name(name) ⇒ Mongo::Client
Get a client with the provided name.
63 64 65 66 67 68 69 |
# File 'build/mongoid-6.1/lib/mongoid/clients.rb', line 63 def with_name(name) name_as_symbol = name.to_sym return clients[name_as_symbol] if clients[name_as_symbol] CREATE_LOCK.synchronize do clients[name_as_symbol] ||= Clients::Factory.create(name) end end |