Class: Kustomize::Json6902Patch::ReplaceOp
- Defined in:
- lib/kustomize/json_6902_patch/replace_op.rb
Class Method Summary collapse
Instance Method Summary collapse
- #apply(rc) ⇒ Object
-
#initialize(path:, value:) ⇒ ReplaceOp
constructor
A new instance of ReplaceOp.
Methods inherited from Op
Constructor Details
#initialize(path:, value:) ⇒ ReplaceOp
Returns a new instance of ReplaceOp.
11 12 13 14 |
# File 'lib/kustomize/json_6902_patch/replace_op.rb', line 11 def initialize(path:, value:) @lens = parse_lens(path) @new_value = value end |
Class Method Details
.create(patch_spec) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/kustomize/json_6902_patch/replace_op.rb', line 4 def self.create(patch_spec) new( path: patch_spec['path'], value: patch_spec['value'] ) end |
Instance Method Details
#apply(rc) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/kustomize/json_6902_patch/replace_op.rb', line 16 def apply(rc) @lens.update_in(rc) do |orig_value| if orig_value.nil? raise ArgumentError, "cannot set value at #{@lens.inspect} -- target does not exist" end [:set, @new_value] end end |