Module: Mongoid::Clients::Options::Threaded

Included in:
ClassMethods, Proxy
Defined in:
lib/mongoid/clients/options.rb

Instance Method Summary collapse

Instance Method Details

#client_with_options(klass = self) ⇒ Mongo::Client

Get the client with special options for the current thread.

Examples:

Get the client with options.

Threaded.client_with_options(Band)

Parameters:

  • klass (Class) (defaults to: self)

    The model class.

Returns:

  • (Mongo::Client)

    The client.

Since:

  • 5.1.0



90
91
92
# File 'lib/mongoid/clients/options.rb', line 90

def client_with_options(klass = self)
  Thread.current["[mongoid][#{klass}]:mongo-client"]
end

#persistence_options(klass = self) ⇒ Hash

Get the persistence options for the current thread.

Examples:

Get the persistence options.

Threaded.persistence_options(Band)

Parameters:

  • klass (Class) (defaults to: self)

    The model class.

Returns:

  • (Hash)

    The current persistence options.

Since:

  • 4.0.0



76
77
78
# File 'lib/mongoid/clients/options.rb', line 76

def persistence_options(klass = self)
  Thread.current["[mongoid][#{klass}]:persistence-options"]
end