lib/mongo/server/connection_pool.rb
# Yield the block to a connection, while handling check in/check out logic.
#
# @example Execute with a connection.
#   pool.with_connection do |connection|
#     connection.read
#   end
#
# @return [ Object ] The result of the block.
#
# @since 2.0.0
Yield the block to a connection, while handling check in/check out logic.
Yield the block to a connection while handling check in / check out logic .
def with_connection(service_id: nil)
        raise_if_closed!
        connection = check_out(service_id: service_id)
        yield(connection)
      ensure
        if connection
          check_in(connection)
        end
      end
def with_connection ( service_id : nil ) raise_if_closed! connection = check_out ( service_id : service_id ) yield ( connection ) ensure if connection check_in ( connection ) end end
Yield the block to a connection, while handling check in/check out logic.
Yield the block to a connection while handling check in / check out logic .
The result of the block.
The result of the block .
 Object 
service_id
example
Execute with a connection. pool.with_connection do |connection| connection.read end
Execute with a connection . pool . with_connection do |connection| connection . read end
since
None