Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/tooling/ruby.rb

Overview

####### ######## ####### ######## ########

 / / / /    License    \ \ \ \ 
Copyleft culture, Copyright (C) is prohibited here
This work is licensed under a CC BY-SA 4.0
Creative Commons Attribution-ShareAlike 4.0 License
Refer to the http://creativecommons.org/licenses/by-sa/4.0/
#######    ########    #######    ########    ########
/ / / /    Code Climate    \ \ \ \ 
Language = ruby
Indent = space;    2 chars;
#######    ########    #######    ########    ########

Instance Method Summary collapse

Instance Method Details

#diff(other) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/tooling/ruby.rb', line 13

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