123456789_123456789_123456789_123456789_123456789_

Class: Mongo::Protocol::GetMore::Upconverter

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

Overview

Converts legacy getMore messages to the appropriare OP_COMMAND style message.

Since:

  • 2.1.0

Constant Summary

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(collection, cursor_id, number_to_return) ⇒ Upconverter

Instantiate the upconverter.

Examples:

Instantiate the upconverter.

Upconverter.new('users', 1, 1)

Parameters:

  • collection (String)

    The name of the collection.

  • cursor_id (Integer)

    The cursor id.

  • number_to_return (Integer)

    The number of documents to return.

Since:

  • 2.1.0

[ GitHub ]

  
# File 'lib/mongo/protocol/get_more.rb', line 139

def initialize(collection, cursor_id, number_to_return)
  @collection = collection
  @cursor_id = cursor_id
  @number_to_return = number_to_return
end

Instance Attribute Details

#collectionString (readonly)

Returns:

  • (String)

    collection The name of the collection.

Since:

  • 2.1.0

[ GitHub ]

  
# File 'lib/mongo/protocol/get_more.rb', line 120

attr_reader :collection

#cursor_idInteger (readonly)

Returns:

  • (Integer)

    cursor_id The cursor id.

Since:

  • 2.1.0

[ GitHub ]

  
# File 'lib/mongo/protocol/get_more.rb', line 123

attr_reader :cursor_id

#number_to_returnInteger (readonly)

Returns:

  • (Integer)

    number_to_return The number of docs to return.

Since:

  • 2.1.0

[ GitHub ]

  
# File 'lib/mongo/protocol/get_more.rb', line 126

attr_reader :number_to_return

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/get_more.rb', line 153

def command
  document = BSON::Document.new
  document.store('getMore', BSON::Int64.new(cursor_id))
  document.store(Message::BATCH_SIZE, number_to_return)
  document.store(Message::COLLECTION, collection)
  document
end