Class: Orchestrate::KeyValue::OperationSet
- Inherits:
-
Object
- Object
- Orchestrate::KeyValue::OperationSet
- Defined in:
- lib/orchestrate/key_value.rb
Overview
An object which builds a set of operations for manipulating an Orchestrate::KeyValue
patch-operations collapse
-
#key_value ⇒ KeyValue
readonly
The keyvalue this object will manipulate.
-
#operations ⇒ Object
readonly
Operations to be performed.
patch-operations collapse
- #add(path, value) ⇒ Object
- #copy(from_path, to_path) ⇒ Object
- #decrement(path, amount) ⇒ Object (also: #dec)
- #increment(path, amount) ⇒ Object (also: #inc)
-
#initialize(key_value, operations = []) ⇒ OperationSet
constructor
Initialize a new OperationSet object.
- #move(from_path, to_path) ⇒ Object
- #remove(path) ⇒ Object
- #replace(path, value) ⇒ Object
- #test(path, value) ⇒ Object
- #update(ref = nil) ⇒ Object
Constructor Details
#initialize(key_value, operations = []) ⇒ OperationSet
Initialize a new OperationSet object
340 341 342 343 |
# File 'lib/orchestrate/key_value.rb', line 340 def initialize(key_value, operations=[]) @key_value = key_value @operations = operations end |
Instance Attribute Details
#key_value ⇒ KeyValue (readonly)
Returns The keyvalue this object will manipulate.
333 334 335 |
# File 'lib/orchestrate/key_value.rb', line 333 def key_value @key_value end |
#operations ⇒ Object (readonly)
Returns operations to be performed.
336 337 338 |
# File 'lib/orchestrate/key_value.rb', line 336 def operations @operations end |
Instance Method Details
#add(path, value) ⇒ Object
349 350 351 |
# File 'lib/orchestrate/key_value.rb', line 349 def add(path, value) self.class.new(key_value, operations.push({op: "add", path: "#{path}", value: value})) end |
#copy(from_path, to_path) ⇒ Object
365 366 367 |
# File 'lib/orchestrate/key_value.rb', line 365 def copy(from_path, to_path) self.class.new(key_value, operations.push({op: "copy", from: "#{from_path}", path: "#{to_path}"})) end |
#decrement(path, amount) ⇒ Object Also known as: dec
374 375 376 |
# File 'lib/orchestrate/key_value.rb', line 374 def decrement(path, amount) self.class.new(key_value, operations.push({op: "inc", path: "#{path}", value: -amount})) end |
#increment(path, amount) ⇒ Object Also known as: inc
369 370 371 |
# File 'lib/orchestrate/key_value.rb', line 369 def increment(path, amount) self.class.new(key_value, operations.push({op: "inc", path: "#{path}", value: amount})) end |
#move(from_path, to_path) ⇒ Object
361 362 363 |
# File 'lib/orchestrate/key_value.rb', line 361 def move(from_path, to_path) self.class.new(key_value, operations.push({op: "move", from: "#{from_path}", path: "#{to_path}"})) end |
#remove(path) ⇒ Object
353 354 355 |
# File 'lib/orchestrate/key_value.rb', line 353 def remove(path) self.class.new(key_value, operations.push({op: "remove", path: "#{path}"})) end |
#replace(path, value) ⇒ Object
357 358 359 |
# File 'lib/orchestrate/key_value.rb', line 357 def replace(path, value) self.class.new(key_value, operations.push({op: "replace", path: "#{path}", value: value})) end |
#test(path, value) ⇒ Object
379 380 381 |
# File 'lib/orchestrate/key_value.rb', line 379 def test(path, value) self.class.new(key_value, operations.push({op: "test", path: "#{path}", value: value})) end |
#update(ref = nil) ⇒ Object
345 346 347 |
# File 'lib/orchestrate/key_value.rb', line 345 def update(ref=nil) key_value.perform(:patch, operations, ref) end |