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

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



155
156
157
158
159
# File 'lib/mongo/protocol/reply.rb', line 155

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



140
141
142
# File 'lib/mongo/protocol/reply.rb', line 140

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



137
138
139
# File 'lib/mongo/protocol/reply.rb', line 137

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



143
144
145
# File 'lib/mongo/protocol/reply.rb', line 143

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



169
170
171
# File 'lib/mongo/protocol/reply.rb', line 169

def command
  command? ? op_command : find_command
end