lib/acts_as_diffable.rb
# Helper for handing objects with an attributes hash (a la ARec).
Helper for handing objects with an attributes hash (a la ARec).
Helper for handing objects with an attributes hash ( a la ARec ) .
def attributes_diff(left, right, ignore = [:id])
          left_attributes = case
            when left.is_a?(Hash) then
              left
            when left.respond_to?(:attributes) then
              left.attributes
            else
              left.instance_values
            end
          right_attributes = case
            when right.is_a?(Hash) then
              right
            when right.respond_to?(:attributes) then
              right.attributes
            else
              right.instance_values
            end
          if left_attributes == right_attributes
            return nil
          else
            generate_diff_hash(left_attributes, right_attributes, *ignore)
          end
        end
def attributes_diff ( left , right , ignore = [ :id ] ) left_attributes = case when left . is_a? ( Hash ) then left when left . respond_to? ( :attributes ) then left . attributes else left . instance_values end right_attributes = case when right . is_a? ( Hash ) then right when right . respond_to? ( :attributes ) then right . attributes else right . instance_values end if left_attributes == right_attributes return nil else generate_diff_hash ( left_attributes , right_attributes , * ignore ) end end
Helper for handing objects with an attributes hash (a la ARec).
Helper for handing objects with an attributes hash ( a la ARec ) .
left
<not_specific>
right
<not_specific>
ignore
<not_specific>