Class: JGrouper::ExportFileDiff
- Inherits:
-
Object
- Object
- JGrouper::ExportFileDiff
- Defined in:
- lib/jgrouper/export_file_diff.rb
Overview
JGrouper::ExportFileDiff - Difference between two JGrouper::ExportFileEntry objects
WARNING
The output format is unstable and will change in a future release.
USAGE
require 'jgrouper'
require 'jgrouper/export_file_diff'
require 'jgrouper/export_file_entry'
diff = JGrouper::ExportFileDiff JGrouper::ExportFileEntry.new(json), JGrouper::ExportFileEntry.new(json)
Instance Method Summary collapse
- #different? ⇒ Boolean
-
#initialize(src, dst) ⇒ ExportFileDiff
constructor
A new instance of ExportFileDiff.
- #to_hash ⇒ Object
- #to_json ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(src, dst) ⇒ ExportFileDiff
Returns a new instance of ExportFileDiff.
22 23 24 25 26 27 |
# File 'lib/jgrouper/export_file_diff.rb', line 22 def initialize(src, dst) @dst = dst @key = dst.key || src.key @src = src @diff = HashDiff.diff @src.json, @dst.json end |
Instance Method Details
#different? ⇒ Boolean
29 30 31 |
# File 'lib/jgrouper/export_file_diff.rb', line 29 def different? !@diff.empty? end |
#to_hash ⇒ Object
37 38 39 40 |
# File 'lib/jgrouper/export_file_diff.rb', line 37 def to_hash return {} unless different? return { entry: @key, changes: @diff } end |
#to_json ⇒ Object
42 43 44 |
# File 'lib/jgrouper/export_file_diff.rb', line 42 def to_json to_hash.to_json end |
#to_s ⇒ Object
33 34 35 |
# File 'lib/jgrouper/export_file_diff.rb', line 33 def to_s { key: @key, diff: @diff }.inspect end |