Class Moped::Protocol::Command
In: lib/moped/protocol/command.rb
Parent: Query

This is a convenience class on top of Query for quickly creating a command.

@example

  command = Moped::Protocol::Command.new :moped, ismaster: 1
  socket.write command.serialize

@since 1.0.0

Methods

Public Class methods

Instantiate the new command.

@example Instantiate the new command.

  Moped::Protocol::Command.new(:moped_test, ismaster: 1)

@param [ String, Symbol ] database The database to run the command on. @param [ Hash ] command The command to run. @param [ Hash ] options And additional query options.

@since 1.0.0

Public Instance methods

Determine if the provided reply message is a failure with respect to a command.

@example Is the reply a command failure?

  command.failure?(reply)

@param [ Reply ] reply The reply to the command.

@return [ true, false ] If the reply is a failure.

@since 2.0.0

Get the exception specific to a failure of this particular operation.

@example Get the failure exception.

  command.failure_exception(document)

@param [ Moped::Protocol::Reply ] reply The reply from the database.

@return [ Moped::Errors::OperationFailure ] The failure exception.

@since 2.0.0

Provide the value that will be logged when the command runs.

@example Provide the log inspection.

  command.log_inspect

@return [ String ] The string value for logging.

@since 1.0.0

Take the provided reply and return the expected results to api consumers. In the case of the command it‘s the first document.

@example Get the expected results of the reply.

  command.results(reply)

@param [ Moped::Protocol::Reply ] reply The reply from the database.

@return [ Hash ] The first document in the reply.

@since 2.0.0

[Validate]