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



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

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



128
129
130
# File 'lib/mongo/protocol/reply.rb', line 128

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



125
126
127
# File 'lib/mongo/protocol/reply.rb', line 125

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



131
132
133
# File 'lib/mongo/protocol/reply.rb', line 131

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



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

def command
  command? ? op_command : find_command
end