Class: Mongo::Protocol::Update::Upconverter
- Inherits:
-
Object
- Object
- Mongo::Protocol::Update::Upconverter
- Defined in:
- 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.
172 173 174 175 176 177 |
# File 'lib/mongo/protocol/update.rb', line 172 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.
145 146 147 |
# File 'lib/mongo/protocol/update.rb', line 145 def collection @collection end |
#filter ⇒ Hash (readonly)
Returns filter The filter.
148 149 150 |
# File 'lib/mongo/protocol/update.rb', line 148 def filter @filter end |
#flags ⇒ Array<Symbol> (readonly)
Returns flags The flags.
154 155 156 |
# File 'lib/mongo/protocol/update.rb', line 154 def flags @flags end |
#update ⇒ Hash (readonly)
Returns update The update.
151 152 153 |
# File 'lib/mongo/protocol/update.rb', line 151 def update @update end |
Instance Method Details
#command ⇒ BSON::Document
Get the upconverted command.
187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/mongo/protocol/update.rb', line 187 def command document = BSON::Document.new updates = BSON::Document.new updates.store(Message::Q, filter) updates.store(U, update) updates.store(MULTI, flags.include?(:multi_update)) updates.store(UPSERT, flags.include?(:upsert)) document.store(UPDATE, collection) document.store(Message::ORDERED, true) document.store(UPDATES, [ updates ]) document end |