class Mongo::Protocol::KillCursors::Upconverter

Converts legacy insert messages to the appropriare OP_COMMAND style message.

@since 2.1.0

Attributes

collection[R]

@return [ String ] collection The name of the collection.

cursor_ids[R]

@return [ Array<Integer> ] cursor_ids The cursor ids.

Public Class Methods

new(collection, cursor_ids) click to toggle source

Instantiate the upconverter.

@example Instantiate the upconverter.

Upconverter.new('users', [ 1, 2, 3 ])

@param [ String ] collection The name of the collection. @param [ Array<Integer> ] cursor_ids The cursor ids.

@since 2.1.0

# File lib/mongo/protocol/kill_cursors.rb, line 103
def initialize(collection, cursor_ids)
  @collection = collection
  @cursor_ids = cursor_ids
end

Public Instance Methods

command() click to toggle source

Get the upconverted command.

@example Get the command.

upconverter.command

@return [ BSON::Document ] The upconverted command.

@since 2.1.0

# File lib/mongo/protocol/kill_cursors.rb, line 116
def command
  document = BSON::Document.new
  document.store('killCursors', collection)
  store_ids = cursor_ids.map do |cursor_id|
    BSON::Int64.new(cursor_id)
  end
  document.store('cursors', store_ids)
  document
end