Module: Mongo::Operation::Executable

Included in:
Commands::CollectionsInfo, Commands::Command, Commands::UserQuery, KillCursors, Read::GetMore, Read::Query
Defined in:
lib/mongo/operation/executable.rb

Overview

This module provides the #execute method that many operations use. It makes sure to instantiate the appropriate Result class for the operation's response.

Since:

  • 2.0.0

Instance Method Summary collapse

Instance Method Details

#execute(server) ⇒ Result

Execute the operation.

Examples:

Execute the operation.

operation.execute(server)

Parameters:

  • server (Mongo::Server)

    The server to send this operation to.

Returns:

  • (Result)

    The operation response, if there is one.

Since:

  • 2.0.0



34
35
36
37
38
39
# File 'lib/mongo/operation/executable.rb', line 34

def execute(server)
  server.with_connection do |connection|
    result_class = self.class.const_defined?(:Result, false) ? self.class::Result : Result
    result_class.new(connection.dispatch([ message(server) ], operation_id)).validate!
  end
end