Class: Mongo::Protocol::Reply::Upconverter
| Relationships & Source Files | |
| Inherits: | Object |
| Defined in: | lib/mongo/protocol/reply.rb |
Overview
Upconverts legacy replies to new op command replies.
Constant Summary
-
CURSOR =
# File 'lib/mongo/protocol/reply.rb', line 129
::Mongo::Cursorfield constant.'cursor' -
FIRST_BATCH =
# File 'lib/mongo/protocol/reply.rb', line 124
First batch constant.
'firstBatch' -
ID =
# File 'lib/mongo/protocol/reply.rb', line 134
::Mongo::Idfield constant.'id' -
NEXT_BATCH =
# File 'lib/mongo/protocol/reply.rb', line 119
Next batch constant.
'nextBatch'
Class Method Summary
-
.new(documents, cursor_id, starting_from) ⇒ Upconverter
constructor
Initialize the new upconverter.
Instance Attribute Summary
-
#command ⇒ BSON::Document
readonly
Get the upconverted command.
- #cursor_id ⇒ Integer readonly
- #documents ⇒ Array<BSON::Document> readonly
- #starting_from ⇒ Integer readonly
- #command? ⇒ Boolean readonly private
Instance Method Summary
- #batch_field private
- #find_command private
- #op_command private
Constructor Details
.new(documents, cursor_id, starting_from) ⇒ Upconverter
Initialize the new upconverter.
# 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
#command ⇒ BSON::Document (readonly)
Get the upconverted command.
# File 'lib/mongo/protocol/reply.rb', line 169
def command command? ? op_command : find_command end
#command? ⇒ Boolean (readonly, private)
#cursor_id ⇒ Integer (readonly)
# File 'lib/mongo/protocol/reply.rb', line 156
attr_reader :cursor_id
#documents ⇒ Array<BSON::Document> (readonly)
# File 'lib/mongo/protocol/reply.rb', line 153
attr_reader :documents
#starting_from ⇒ Integer (readonly)
# File 'lib/mongo/protocol/reply.rb', line 159
attr_reader :starting_from
Instance Method Details
#batch_field (private)
# File 'lib/mongo/protocol/reply.rb', line 175
def batch_field (starting_from > 0) ? NEXT_BATCH : FIRST_BATCH end
#find_command (private)
# File 'lib/mongo/protocol/reply.rb', line 183
def find_command document = BSON::Document.new cursor_document = BSON::Document.new cursor_document.store(ID, cursor_id) cursor_document.store(batch_field, documents) document.store(Operation::Result::OK, 1) document.store(CURSOR, cursor_document) document end
#op_command (private)
# File 'lib/mongo/protocol/reply.rb', line 193
def op_command documents.first end