Class: Hash

Inherits:
Object show all
Includes:
HashRecursiveBlank, HashRecursiveMerge
Defined in:
lib/lib/utils.rb

Instance Method Summary collapse

Methods included from HashRecursiveBlank

#rblank, #rblank!

Methods included from HashRecursiveMerge

#rmerge, #rmerge!

Instance Method Details

#diff(other) ⇒ Object



187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/lib/utils.rb', line 187

def diff(other)
  (self.keys + other.keys).uniq.inject({}) do |memo, key|
    unless self[key] == other[key]
      if self[key].kind_of?(Hash) &&  other[key].kind_of?(Hash)
        memo[key] = self[key].diff(other[key])
      else
        memo[key] = [self[key], other[key]]
      end
    end
    memo
  end
end