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'
FIRST_BATCH =

First batch constant.

Since:

  • 2.1.0

'firstBatch'
CURSOR =

Cursor field constant.

Since:

  • 2.1.0

'cursor'
ID =

Id field constant.

Since:

  • 2.1.0

'id'

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



146
147
148
149
150
# File 'lib/mongo/protocol/reply.rb', line 146

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



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

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



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

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



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

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