module Lutaml::Model::ComparableModel::ClassMethods
def diff_tree
-
(String)
- A string representation of the diff tree
Parameters:
-
options
(Hash
) -- Options for diff generation -
obj2
(Object
) -- The second object to compare -
obj1
(Object
) -- The first object to compare
def diff_tree if @obj1.nil? && @obj2.nil? @root_tree = Tree.new("Both objects are nil") elsif @obj1.nil? @root_tree = Tree.new("First object is nil") format_single_value(@obj2, @root_tree, @obj2.class.to_s) elsif @obj2.nil? @root_tree = Tree.new("Second object is nil") format_single_value(@obj1, @root_tree, @obj1.class.to_s) else traverse_diff do |name, type, value1, value2, is_last| format_attribute_diff(name, type, value1, value2, is_last) end end @root_tree.to_s end
def diff_with_score(obj1, obj2, **options)
-
(Array
- An array containing the normalized diff score and the diff tree)
Parameters:
-
options
(Hash
) -- Options for diff generation -
obj2
(Object
) -- The second object to compare -
obj1
(Object
) -- The first object to compare
def diff_with_score(obj1, obj2, **options) context = DiffContext.new(obj1, obj2, **options) indent = options[:indent] || "" [context.calculate_diff_score, context.diff_tree(indent)] end