Class: Moped::Protocol::Command

Inherits:
Query show all
Defined in:
lib/moped/protocol/command.rb

Overview

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

Examples:

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

Direct Known Subclasses

Moped::Protocol::Commands::Authenticate

Instance Attribute Summary

Attributes inherited from Query

#batch_size, #collection, #database, #fields, #flags, #full_collection_name, #length, #limit, #op_code, #request_id, #selector, #skip

Instance Method Summary collapse

Methods inherited from Query

#basic_selector, #no_timeout=, #receive_replies

Methods included from Message

included, #inspect, #receive_replies, #serialize

Constructor Details

#initialize(database, command, options = {}) ⇒ Command

Returns a new instance of Command.

Parameters:

  • database (String, Symbol)

    the database to run this command on

  • command (Hash)

    the command to run

  • additional (Hash)

    query options



15
16
17
# File 'lib/moped/protocol/command.rb', line 15

def initialize(database, command, options = {})
  super database, '$cmd', command, options.merge(limit: -1)
end

Instance Method Details

#log_inspectObject



19
20
21
22
# File 'lib/moped/protocol/command.rb', line 19

def log_inspect
  type = "COMMAND"
  "%-12s database=%s command=%s" % [type, database, selector.inspect]
end