module Mongo::Operation::OpMsgExecutable

Shared behavior of executing the operation as an OpMsg.

@api private

Public Instance Methods

execute(server, context:, options: {}) click to toggle source

Execute the operation.

@param [ Mongo::Server ] server The server to send the operation to. @param [ Operation::Context ] context The operation context. @param [ Hash ] options Operation execution options.

@return [ Mongo::Operation::Result ] The operation result.

# File lib/mongo/operation/shared/op_msg_executable.rb, line 33
def execute(server, context:, options: {})
  server.with_connection(connection_global_id: context.connection_global_id) do |connection|
    execute_with_connection(connection, context: context, options: options)
  end
end
execute_with_connection(connection, context:, options: {}) click to toggle source

Execute the operation.

@param [ Mongo::Server::Connection ] connection The connection to send

the operation through.

@param [ Operation::Context ] context The operation context. @param [ Hash ] options Operation execution options.

@return [ Mongo::Operation::Result ] The operation result.

# File lib/mongo/operation/shared/op_msg_executable.rb, line 47
def execute_with_connection(connection, context:, options: {})
  final_operation.execute(connection, context: context, options: options)
end

Private Instance Methods

final_operation() click to toggle source
# File lib/mongo/operation/shared/op_msg_executable.rb, line 53
def final_operation
  polymorphic_class(self.class.name, :OpMsg).new(spec)
end