Module: Mongo::Operation::PolymorphicOperation Private

Included in:
CollectionsInfo, Indexes, OpMsgOrCommand, OpMsgOrFindCommand
Defined in:
build/ruby-driver-master/lib/mongo/operation/shared/polymorphic_operation.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Shared behavior of implementing an operation differently based on the server that will be executing the operation.

Instance Method Summary collapse

Instance Method Details

#execute(server, context:, options: {}) ⇒ Mongo::Operation::Result

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Execute the operation.

Parameters:

  • server (Mongo::Server)

    The server to send the operation to.

  • context (Operation::Context)

    The operation context.

  • options (Hash) (defaults to: {})

    Operation execution options.

Returns:



34
35
36
37
38
# File 'build/ruby-driver-master/lib/mongo/operation/shared/polymorphic_operation.rb', line 34

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: {}) ⇒ Mongo::Operation::Result

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Execute the operation.

Parameters:

Returns:



48
49
50
51
# File 'build/ruby-driver-master/lib/mongo/operation/shared/polymorphic_operation.rb', line 48

def execute_with_connection(connection, context:, options: {})
  operation = final_operation(connection)
  operation.execute(connection, context: context, options: options)
end