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

Inherits:
Object
  • Object
show all
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

GET_MORE =

The get more constant.

Since:

  • 2.2.0

'getMore'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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



135
136
137
138
139
# File 'lib/mongo/protocol/get_more.rb', line 135

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 collection The name of the collection.

Returns:

  • (String)

    collection The name of the collection.

Since:

  • 2.1.0



116
117
118
# File 'lib/mongo/protocol/get_more.rb', line 116

def collection
  @collection
end

#cursor_idInteger (readonly)

Returns cursor_id The cursor id.

Returns:

  • (Integer)

    cursor_id The cursor id.

Since:

  • 2.1.0



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

def cursor_id
  @cursor_id
end

#number_to_returnInteger (readonly)

Returns number_to_return The number of docs to return.

Returns:

  • (Integer)

    number_to_return The number of docs to return.

Since:

  • 2.1.0



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

def number_to_return
  @number_to_return
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



149
150
151
152
153
154
155
# File 'lib/mongo/protocol/get_more.rb', line 149

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