Class: Mongo::Protocol::Insert::Upconverter
- Inherits:
-
Object
- Object
- Mongo::Protocol::Insert::Upconverter
- Defined in:
- lib/mongo/protocol/insert.rb
Overview
Converts legacy insert messages to the appropriare OP_COMMAND style message.
Constant Summary collapse
- INSERT =
Insert field constant.
'insert'.freeze
- DOCUMENTS =
Documents field constant.
'documents'.freeze
- WRITE_CONCERN =
Write concern field constant.
'writeConcern'.freeze
Instance Attribute Summary collapse
-
#collection ⇒ String
readonly
Collection The name of the collection.
-
#documents ⇒ Array<BSON::Document>
readonly
Documents The documents to insert.
-
#options ⇒ Hash
readonly
Options The options.
Instance Method Summary collapse
-
#command ⇒ BSON::Document
Get the upconverted command.
-
#initialize(collection, documents, options) ⇒ Upconverter
constructor
Instantiate the upconverter.
Constructor Details
#initialize(collection, documents, options) ⇒ Upconverter
Instantiate the upconverter.
141 142 143 144 145 |
# File 'lib/mongo/protocol/insert.rb', line 141 def initialize(collection, documents, ) @collection = collection @documents = documents @options = end |
Instance Attribute Details
#collection ⇒ String (readonly)
Returns collection The name of the collection.
123 124 125 |
# File 'lib/mongo/protocol/insert.rb', line 123 def collection @collection end |
#documents ⇒ Array<BSON::Document> (readonly)
Returns documents The documents to insert.
126 127 128 |
# File 'lib/mongo/protocol/insert.rb', line 126 def documents @documents end |
#options ⇒ Hash (readonly)
Returns options The options.
129 130 131 |
# File 'lib/mongo/protocol/insert.rb', line 129 def @options end |
Instance Method Details
#command ⇒ BSON::Document
Get the upconverted command.
155 156 157 158 159 160 161 162 |
# File 'lib/mongo/protocol/insert.rb', line 155 def command document = BSON::Document.new document.store(INSERT, collection) document.store(DOCUMENTS, documents) document.store(Message::ORDERED, .fetch(:ordered, true)) document.merge!(WRITE_CONCERN => [:write_concern].) if [:write_concern] document end |