Class: JSONP3::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.
303 304 305 306 307 |
# File 'lib/json_p3/patch.rb', line 303 def initialize(pointer, value) super() @pointer = pointer @value = value end |
Instance Method Details
#apply(value, index) ⇒ Object
313 314 315 316 317 318 |
# File 'lib/json_p3/patch.rb', line 313 def apply(value, index) obj = @pointer.resolve(value) raise JSONPatchTestFailure, "test failed (#{name}:#{index})" if obj != @value value end |
#name ⇒ Object
309 310 311 |
# File 'lib/json_p3/patch.rb', line 309 def name "test" end |
#to_h ⇒ Object
320 321 322 |
# File 'lib/json_p3/patch.rb', line 320 def to_h { "op" => name, "path" => @pointer.to_s, "value" => @value } end |