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

Inherits:
Object
  • Object
show all
Defined in:
build/ruby-driver-master/lib/mongo/protocol/kill_cursors.rb

Overview

Converts legacy insert messages to the appropriare OP_COMMAND style message.

Since:

  • 2.1.0

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



106
107
108
109
# File 'build/ruby-driver-master/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 collection The name of the collection.

Returns:

  • (String)

    collection The name of the collection.

Since:

  • 2.1.0



92
93
94
# File 'build/ruby-driver-master/lib/mongo/protocol/kill_cursors.rb', line 92

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



95
96
97
# File 'build/ruby-driver-master/lib/mongo/protocol/kill_cursors.rb', line 95

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



119
120
121
122
123
124
125
126
127
# File 'build/ruby-driver-master/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