Module: Mongo::Operation::Write::WriteCommandEnabled

Included in:
CreateIndex, CreateUser, Delete, DropIndex, Insert, RemoveUser, Update, UpdateUser
Defined in:
lib/mongo/operation/write/write_command_enabled.rb

Overview

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

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 result.

Since:

  • 2.1.0



36
37
38
39
40
41
42
43
# File 'lib/mongo/operation/write/write_command_enabled.rb', line 36

def execute(server)
  if !server.features.write_command_enabled? || unacknowledged_write?
    raise Error::UnsupportedCollation.new(Error::UnsupportedCollation::UNACKNOWLEDGED_WRITES_MESSAGE) if has_collation?
    execute_message(server)
  else
    execute_write_command(server)
  end
end