aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/hash/diff.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/core_ext/hash/diff.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/hash/diff.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/hash/diff.rb b/activesupport/lib/active_support/core_ext/hash/diff.rb
new file mode 100644
index 0000000000..deace40a29
--- /dev/null
+++ b/activesupport/lib/active_support/core_ext/hash/diff.rb
@@ -0,0 +1,11 @@
+module ActiveSupport #:nodoc:
+ module CoreExtensions #:nodoc:
+ module Hash #:nodoc:
+ module Diff
+ def diff(h2)
+ self.dup.delete_if { |k, v| h2[k] == v }.merge(h2.dup.delete_if { |k, v| self.has_key?(k) })
+ end
+ end
+ end
+ end
+end