Class: Mongo::Protocol::Insert::Upconverter
- Inherits:
-
Object
- Object
- Mongo::Protocol::Insert::Upconverter
- Defined in:
- build/ruby-driver-master/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.
154 155 156 157 158 |
# File 'build/ruby-driver-master/lib/mongo/protocol/insert.rb', line 154 def initialize(collection, documents, ) @collection = collection @documents = documents @options = end |
Instance Attribute Details
#collection ⇒ String (readonly)
Returns collection The name of the collection.
136 137 138 |
# File 'build/ruby-driver-master/lib/mongo/protocol/insert.rb', line 136 def collection @collection end |
#documents ⇒ Array<BSON::Document> (readonly)
Returns documents The documents to insert.
139 140 141 |
# File 'build/ruby-driver-master/lib/mongo/protocol/insert.rb', line 139 def documents @documents end |
#options ⇒ Hash (readonly)
Returns options The options.
142 143 144 |
# File 'build/ruby-driver-master/lib/mongo/protocol/insert.rb', line 142 def @options end |
Instance Method Details
#command ⇒ BSON::Document
Get the upconverted command.
168 169 170 171 172 173 174 175 |
# File 'build/ruby-driver-master/lib/mongo/protocol/insert.rb', line 168 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 |