Module: JSON
- Defined in:
- lib/json/merge_patch/version.rb,
lib/json/merge_patch.rb,
lib/json/merge_patch/railtie.rb
Overview
The Ruby standard Library exports JSON www.ruby-doc.org/stdlib-1.9.3/libdoc/json/rdoc/
Defined Under Namespace
Classes: MergePatch
Constant Summary collapse
- MergeError =
This represents an error that occurs during merging.
Class.new(StandardError)
Class Method Summary collapse
-
.merge(document, merge_patch) ⇒ String
Merges a patch into the existing JSON document.
Class Method Details
.merge(document, merge_patch) ⇒ String
Merges a patch into the existing JSON document.
15 16 17 18 19 20 21 |
# File 'lib/json/merge_patch.rb', line 15 def self.merge(document, merge_patch) orig = JSON.parse(document) patch = JSON.parse(merge_patch) JSON.dump(MergePatch.new(orig, patch).call) rescue raise MergeError end |