Class: Mongo::Protocol::Update::Upconverter
- Inherits:
-
Object
- Object
- Mongo::Protocol::Update::Upconverter
- Defined in:
- build/ruby-driver-v2.17/lib/mongo/protocol/update.rb
Overview
Converts legacy update messages to the appropriare OP_COMMAND style message.
Constant Summary collapse
- MULTI =
The multi constant.
'multi'.freeze
- U =
The u constant.
'u'.freeze
- UPDATE =
The update constant.
'update'.freeze
- UPDATES =
The updates constant.
'updates'.freeze
- UPSERT =
The upsert constant.
'upsert'.freeze
Instance Attribute Summary collapse
-
#collection ⇒ String
readonly
Collection The name of the collection.
-
#filter ⇒ Hash
readonly
Filter The filter.
-
#flags ⇒ Array<Symbol>
readonly
Flags The flags.
-
#update ⇒ Hash
readonly
Update The update.
Instance Method Summary collapse
-
#command ⇒ BSON::Document
Get the upconverted command.
-
#initialize(collection, filter, update, flags) ⇒ Upconverter
constructor
Instantiate the upconverter.
Constructor Details
#initialize(collection, filter, update, flags) ⇒ Upconverter
Instantiate the upconverter.
178 179 180 181 182 183 |
# File 'build/ruby-driver-v2.17/lib/mongo/protocol/update.rb', line 178 def initialize(collection, filter, update, flags) @collection = collection @filter = filter @update = update @flags = flags end |
Instance Attribute Details
#collection ⇒ String (readonly)
Returns collection The name of the collection.
151 152 153 |
# File 'build/ruby-driver-v2.17/lib/mongo/protocol/update.rb', line 151 def collection @collection end |
#filter ⇒ Hash (readonly)
Returns filter The filter.
154 155 156 |
# File 'build/ruby-driver-v2.17/lib/mongo/protocol/update.rb', line 154 def filter @filter end |
#flags ⇒ Array<Symbol> (readonly)
Returns flags The flags.
160 161 162 |
# File 'build/ruby-driver-v2.17/lib/mongo/protocol/update.rb', line 160 def flags @flags end |
#update ⇒ Hash (readonly)
Returns update The update.
157 158 159 |
# File 'build/ruby-driver-v2.17/lib/mongo/protocol/update.rb', line 157 def update @update end |
Instance Method Details
#command ⇒ BSON::Document
Get the upconverted command.
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'build/ruby-driver-v2.17/lib/mongo/protocol/update.rb', line 193 def command document = BSON::Document.new updates = BSON::Document.new updates.store(Message::Q, filter) updates.store(U, update) if flags.include?(:multi_update) updates.store(MULTI, true) end if flags.include?(:upsert) updates.store(UPSERT, true) end document.store(UPDATE, collection) document.store(Message::ORDERED, true) document.store(UPDATES, [ updates ]) document end |