Class: Mongo::Server::Context Deprecated

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/mongo/server/context.rb

Overview

Deprecated.

Will be removed in version 3.0

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

Since:

  • 2.0.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server) ⇒ Context

Instantiate a server context.

Examples:

Instantiate a server context.

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

Parameters:

Since:

  • 2.0.0



49
50
51
# File 'lib/mongo/server/context.rb', line 49

def initialize(server)
  @server = server
end

Instance Attribute Details

#serverMongo::Server (readonly)

Returns server The server the context is for.

Returns:

Since:

  • 2.0.0



28
29
30
# File 'lib/mongo/server/context.rb', line 28

def server
  @server
end

Instance Method Details

#with_connection(&block) ⇒ Object

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

Examples:

Send a message with the connection.

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

Returns:

  • (Object)

    The result of the block execution.

Since:

  • 2.0.0



64
65
66
# File 'lib/mongo/server/context.rb', line 64

def with_connection(&block)
  server.pool.with_connection(&block)
end