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

Inherits:
Object
  • Object
show all
Defined in:
lib/mongo/protocol/kill_cursors.rb

Overview

Converts legacy insert messages to the appropriare OP_COMMAND style message.

Since:

  • 2.1.0

Constant Summary

KILL_CURSORS =

The kill cursors constant.

Since:

  • 2.2.0

'killCursors'.freeze
CURSORS =

The cursors constant.

Since:

  • 2.2.0

'cursors'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(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



113
114
115
116
# File 'lib/mongo/protocol/kill_cursors.rb', line 113

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

Instance Attribute Details

#collectionString (readonly)

Returns collection The name of the collection.

Returns:

  • (String)

    collection The name of the collection.

Since:

  • 2.1.0



99
100
101
# File 'lib/mongo/protocol/kill_cursors.rb', line 99

def collection
  @collection
end

#cursor_idsArray<Integer> (readonly)

Returns cursor_ids The cursor ids.

Returns:

  • (Array<Integer>)

    cursor_ids The cursor ids.

Since:

  • 2.1.0



102
103
104
# File 'lib/mongo/protocol/kill_cursors.rb', line 102

def cursor_ids
  @cursor_ids
end

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



126
127
128
129
130
131
# File 'lib/mongo/protocol/kill_cursors.rb', line 126

def command
  document = BSON::Document.new
  document.store(KILL_CURSORS, collection)
  document.store(CURSORS, cursor_ids)
  document
end