class SuperDiff::OperationTreeBuilders::CustomObject
Attributes
actual_attributes[R]
expected_attributes[R]
Public Class Methods
applies_to?(expected, actual)
click to toggle source
# File lib/super_diff/operation_tree_builders/custom_object.rb, line 4 def self.applies_to?(expected, actual) expected.class == actual.class && expected.respond_to?(:attributes_for_super_diff) && actual.respond_to?(:attributes_for_super_diff) end
Protected Instance Methods
attribute_names()
click to toggle source
# File lib/super_diff/operation_tree_builders/custom_object.rb, line 18 def attribute_names expected.attributes_for_super_diff.keys & actual.attributes_for_super_diff.keys end
build_operation_tree()
click to toggle source
# File lib/super_diff/operation_tree_builders/custom_object.rb, line 12 def build_operation_tree # NOTE: It doesn't matter whether we use expected or actual here, # because all we care about is the name of the class OperationTrees::CustomObject.new([], underlying_object: actual) end
Private Instance Methods
establish_expected_and_actual_attributes()
click to toggle source
# File lib/super_diff/operation_tree_builders/custom_object.rb, line 27 def establish_expected_and_actual_attributes @expected_attributes = attribute_names.reduce({}) do |hash, name| hash.merge(name => expected.public_send(name)) end @actual_attributes = attribute_names.reduce({}) do |hash, name| hash.merge(name => actual.public_send(name)) end end