lib/mongo/client.rb
# Creates a new client with the passed options merged over the existing
# options of this client. Useful for one-offs to change specific options
# without altering the original client.
#
# @note Depending on options given, the returned client may share the
#   cluster with the original client or be created with a new cluster.
#   If a new cluster is created, the monitoring event subscribers on
#   the new client are set to the default event subscriber set and
#   none of the subscribers on the original client are copied over.
#
# @example Get a client with changed options.
#   client.with(:read => { :mode => :primary_preferred })
#
# @param [ Hash ] new_options The new options to use.
#
# @return [ Mongo::Client ] A new client instance.
#
# @since 2.0.0
Creates a new client with the passed options merged over the existing
options of this client. Useful for one-offs to change specific options
without altering the original client.
Creates a new client with the passed options merged over the existing options of this client . Useful for one - offs to change specific options without altering the original client .
def with(new_options = Options::Redacted.new)
      clone.tap do |client|
        opts = client.update_options(new_options)
        Database.create(client)
        if cluster_modifying?(opts)
          Cluster.create(client)
        end
      end
    end
def with ( new_options = Options :: Redacted . new ) clone . tap do | client | opts = client . update_options ( new_options ) Database . create ( client ) if cluster_modifying? ( opts ) Cluster . create ( client ) end end end
Creates a new client with the passed options merged over the existing
options of this client.
Creates a new client with the passed options merged over the existing options of this client .
# We can't use the same cluster if some options that would affect it # have changed.
A new client instance.
A new client instance .
 Mongo::Client 
new_options
new
new_options The new options to use.
new_options The new options to use .
note
Depending on options given, the returned client may share the cluster with the original client or be created with a new cluster. If a new cluster is created, the monitoring event subscribers on the new client are set to the default event subscriber set and none of the subscribers on the original client are copied over.
Depending on options given the returned client may share the cluster with the original client or be created with a new cluster . If a new cluster is created the monitoring event subscribers on the new client are set to the default event subscriber set and none of the subscribers on the original client are copied over .
example
Get a client with changed options. client.with(:read => { :mode => :primary_preferred })
Get a client with changed options . client . with ( : read = > { : mode = > : primary_preferred } )
since
None