Created
July 27, 2009 19:43
-
-
Save alissonsales/156691 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Hash | |
def diff(hash) | |
raise ArgumentError, 'Argument is not a Hash' unless hash.is_a? Hash | |
kkeys = [] | |
self.keys.each do |k| | |
diff = self[k].diff(hash[k]) if self[k].is_a? Hash and hash[k].is_a? Hash | |
kkeys << {k => diff} if diff and diff.size > 0 | |
end | |
diff = self.keys - hash.keys | |
kkeys << diff if diff and diff.size > 0 | |
return kkeys | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment