module Mongo::Operation::Write::WriteCommandEnabled

This module contains common functionality for operations that send either a write command or a specific wire protocol message, depending on server version. For server versions >= 2.6, a write command is sent.

@since 2.1.0

Public Instance Methods

execute(context) click to toggle source

Execute the operation.

@example Execute the operation.

operation.execute(context)

@param [ Mongo::Server::Context ] context The context for this operation.

@return [ Result ] The operation result.

@since 2.1.0

# File lib/mongo/operation/write/write_command_enabled.rb, line 36
def execute(context)
  if context.features.write_command_enabled?
    execute_write_command(context)
  else
    execute_message(context)
  end
end

Private Instance Methods

execute_write_command(context) click to toggle source
# File lib/mongo/operation/write/write_command_enabled.rb, line 46
def execute_write_command(context)
  result_class = self.class.const_defined?(:Result, false) ? self.class::Result : Result
  result_class.new(write_command_op.execute(context)).validate!
end