Class: JSONP3::Patch::OpTest
Overview
The JSON Patch test operation.
Instance Method Summary collapse
- #apply!(value, index) ⇒ Object
-
#initialize(pointer, value) ⇒ OpTest
constructor
A new instance of OpTest.
- #name ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(pointer, value) ⇒ OpTest
Returns a new instance of OpTest.
9 10 11 12 13 |
# File 'lib/json_p3/patch/op_test.rb', line 9 def initialize(pointer, value) super() @pointer = pointer @value = value end |
Instance Method Details
#apply!(value, index) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/json_p3/patch/op_test.rb', line 19 def apply!(value, index) obj = @pointer.resolve(value) raise JSONP3::Patch::TestFailure, "test failed (#{name}:#{index})" if obj != @value value end |
#name ⇒ Object
15 16 17 |
# File 'lib/json_p3/patch/op_test.rb', line 15 def name "test" end |
#to_h ⇒ Object
26 27 28 |
# File 'lib/json_p3/patch/op_test.rb', line 26 def to_h { "op" => name, "path" => @pointer.to_s, "value" => @value } end |