class Mongo::Server::Context

Represents a context in which messages are sent to the server on a connection.

@since 2.0.0

@deprecated Will be removed in version 3.0

Attributes

server[R]

@return [ Mongo::Server ] server The server the context is for.

Public Class Methods

new(server) click to toggle source

Instantiate a server context.

@example Instantiate a server context.

Mongo::Server::Context.new(server)

@param [ Mongo::Server ] server The server the context is for.

@since 2.0.0

# File lib/mongo/server/context.rb, line 35
def initialize(server)
  @server = server
end

Public Instance Methods

with_connection(&block) click to toggle source

Execute a block of code with a connection, that is checked out of the pool and then checked back in.

@example Send a message with the connection.

context.with_connection do |connection|
  connection.dispatch([ command ])
end

@return [ Object ] The result of the block execution.

@since 2.0.0

# File lib/mongo/server/context.rb, line 64
def with_connection(&block)
  server.pool.with_connection(&block)
end