Class: Moped::Protocol::Update
- Includes:
- Message
- Defined in:
- lib/moped/protocol/update.rb
Overview
The Protocol class for updating documents in a collection.
Instance Attribute Summary collapse
-
#collection ⇒ String, Symbol
readonly
The collection this insert targets.
-
#database ⇒ String, Symbol
readonly
The database this insert targets.
-
#flags ⇒ Array
The flags for the update message.
-
#full_collection_name ⇒ String
The namespaced collection name.
-
#length ⇒ Number
The length of the message.
-
#op_code ⇒ Number
OP_UPDATE operation code (2001).
-
#request_id ⇒ Number
The request id of the message.
-
#selector ⇒ Hash
The selector for the update.
-
#update ⇒ Hash
The updates to apply.
Instance Method Summary collapse
-
#initialize(database, collection, selector, update, options = {}) ⇒ Update
constructor
Create a new update command.
- #log_inspect ⇒ Object
Methods included from Message
included, #inspect, #receive_replies, #serialize
Constructor Details
#initialize(database, collection, selector, update, options = {}) ⇒ Update
Create a new update command. The database
and collection
arguments are joined together to set the full_collection_name
.
89 90 91 92 93 94 95 96 97 98 |
# File 'lib/moped/protocol/update.rb', line 89 def initialize(database, collection, selector, update, = {}) @database = database @collection = collection @full_collection_name = "#{database}.#{collection}" @selector = selector @update = update @request_id = [:request_id] @flags = [:flags] end |
Instance Attribute Details
#collection ⇒ String, Symbol (readonly)
Returns the collection this insert targets.
71 72 73 |
# File 'lib/moped/protocol/update.rb', line 71 def collection @collection end |
#database ⇒ String, Symbol (readonly)
Returns the database this insert targets.
68 69 70 |
# File 'lib/moped/protocol/update.rb', line 68 def database @database end |
#flags ⇒ Array
The flags for the update message. Supported flags are :upsert
and :multi
.
48 49 |
# File 'lib/moped/protocol/update.rb', line 48 flags :flags, upsert: 2 ** 0, multi: 2 ** 1 |
#full_collection_name ⇒ String
Returns the namespaced collection name.
41 |
# File 'lib/moped/protocol/update.rb', line 41 cstring :full_collection_name |
#length ⇒ Number
Returns the length of the message.
25 |
# File 'lib/moped/protocol/update.rb', line 25 int32 :length |
#op_code ⇒ Number
Returns OP_UPDATE operation code (2001).
35 |
# File 'lib/moped/protocol/update.rb', line 35 int32 :op_code |
#request_id ⇒ Number
Returns the request id of the message.
29 |
# File 'lib/moped/protocol/update.rb', line 29 int32 :request_id |
#selector ⇒ Hash
Returns the selector for the update.
53 |
# File 'lib/moped/protocol/update.rb', line 53 document :selector |
#update ⇒ Hash
Returns the updates to apply.
57 |
# File 'lib/moped/protocol/update.rb', line 57 document :update |
Instance Method Details
#log_inspect ⇒ Object
100 101 102 103 104 105 106 107 |
# File 'lib/moped/protocol/update.rb', line 100 def log_inspect type = "UPDATE" "%-12s database=%s collection=%s selector=%s update=%s flags=%s" % [type, database, collection, selector.inspect, update.inspect, flags.inspect] end |