Class: Mongo::Protocol::Reply::Upconverter

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

Overview

Upconverts legacy replies to new op command replies.

Since:

  • 2.1.0

Constant Summary collapse

NEXT_BATCH =

Next batch constant.

Since:

  • 2.1.0

'nextBatch'.freeze
FIRST_BATCH =

First batch constant.

Since:

  • 2.1.0

'firstBatch'.freeze
CURSOR =

Cursor field constant.

Since:

  • 2.1.0

'cursor'.freeze
ID =

Id field constant.

Since:

  • 2.1.0

'id'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(documents, cursor_id, starting_from) ⇒ Upconverter

Initialize the new upconverter.

Examples:

Create the upconverter.

Upconverter.new(docs, 1, 3)

Parameters:

  • documents (Array<BSON::Document>)

    The documents.

  • cursor_id (Integer)

    The cursor id.

  • starting_from (Integer)

    The starting position.

Since:

  • 2.1.0



152
153
154
155
156
# File 'lib/mongo/protocol/reply.rb', line 152

def initialize(documents, cursor_id, starting_from)
  @documents = documents
  @cursor_id = cursor_id
  @starting_from = starting_from
end

Instance Attribute Details

#cursor_idInteger (readonly)

Returns cursor_id The cursor id.

Returns:

  • (Integer)

    cursor_id The cursor id.

Since:

  • 2.1.0



162
163
164
# File 'lib/mongo/protocol/reply.rb', line 162

def cursor_id
  @cursor_id
end

#documentsArray<BSON::Document> (readonly)

Returns documents The documents.

Returns:

  • (Array<BSON::Document>)

    documents The documents.

Since:

  • 2.1.0



159
160
161
# File 'lib/mongo/protocol/reply.rb', line 159

def documents
  @documents
end

#starting_fromInteger (readonly)

Returns starting_from The starting point in the cursor.

Returns:

  • (Integer)

    starting_from The starting point in the cursor.

Since:

  • 2.1.0



165
166
167
# File 'lib/mongo/protocol/reply.rb', line 165

def starting_from
  @starting_from
end

Instance Method Details

#commandBSON::Document

Get the upconverted command.

Examples:

Get the command.

upconverter.command

Returns:

  • (BSON::Document)

    The command.

Since:

  • 2.1.0



175
176
177
# File 'lib/mongo/protocol/reply.rb', line 175

def command
  command? ? op_command : find_command
end