123456789_123456789_123456789_123456789_123456789_

Class: Mongo::Protocol::KillCursors::Upconverter

Relationships & Source Files
Inherits: Object
Defined in: lib/mongo/protocol/kill_cursors.rb

Overview

Converts legacy insert messages to the appropriare OP_COMMAND style message.

Since:

  • 2.1.0

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(collection, cursor_ids) ⇒ Upconverter

Instantiate the upconverter.

Examples:

Instantiate the upconverter.

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

Parameters:

  • collection (String)

    The name of the collection.

  • cursor_ids (Array<Integer>)

    The cursor ids.

Since:

  • 2.1.0

[ GitHub ]

  
# File 'lib/mongo/protocol/kill_cursors.rb', line 106

def initialize(collection, cursor_ids)
  @collection = collection
  @cursor_ids = cursor_ids
end

Instance Attribute Details

#collectionString (readonly)

Returns:

  • (String)

    collection The name of the collection.

Since:

  • 2.1.0

[ GitHub ]

  
# File 'lib/mongo/protocol/kill_cursors.rb', line 92

attr_reader :collection

#cursor_idsArray<Integer> (readonly)

Returns:

  • (Array<Integer>)

    cursor_ids The cursor ids.

Since:

  • 2.1.0

[ GitHub ]

  
# File 'lib/mongo/protocol/kill_cursors.rb', line 95

attr_reader :cursor_ids

Instance Method Details

#commandBSON::Document

Get the upconverted command.

Examples:

Get the command.

upconverter.command

Returns:

  • (BSON::Document)

    The upconverted command.

Since:

  • 2.1.0

[ GitHub ]

  
# File 'lib/mongo/protocol/kill_cursors.rb', line 119

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