aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2010-11-11 19:39:21 +0100
committerJosé Valim <jose.valim@gmail.com>2010-11-11 19:39:21 +0100
commitf912a359aaaffa04fedb2ffd5730284d629b481a (patch)
treeee0163b662d378ba9dfe327cbbe17f3cde07790c /activesupport/lib
parentde2933e1a062f0752512eb0ec60f7217f4890f8c (diff)
parentcc135e3b6df1785852de2470b4b93559c88c891e (diff)
downloadrails-f912a359aaaffa04fedb2ffd5730284d629b481a.tar.gz
rails-f912a359aaaffa04fedb2ffd5730284d629b481a.tar.bz2
rails-f912a359aaaffa04fedb2ffd5730284d629b481a.zip
Merge remote branch 'drogus/plugin_new'
Conflicts: railties/test/generators/app_generator_test.rb
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/core_ext/hash.rb1
-rw-r--r--activesupport/lib/active_support/core_ext/hash/deep_dup.rb11
2 files changed, 12 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/hash.rb b/activesupport/lib/active_support/core_ext/hash.rb
index 501483498d..fd1cda991e 100644
--- a/activesupport/lib/active_support/core_ext/hash.rb
+++ b/activesupport/lib/active_support/core_ext/hash.rb
@@ -1,5 +1,6 @@
require 'active_support/core_ext/hash/conversions'
require 'active_support/core_ext/hash/deep_merge'
+require 'active_support/core_ext/hash/deep_dup'
require 'active_support/core_ext/hash/diff'
require 'active_support/core_ext/hash/except'
require 'active_support/core_ext/hash/indifferent_access'
diff --git a/activesupport/lib/active_support/core_ext/hash/deep_dup.rb b/activesupport/lib/active_support/core_ext/hash/deep_dup.rb
new file mode 100644
index 0000000000..447142605c
--- /dev/null
+++ b/activesupport/lib/active_support/core_ext/hash/deep_dup.rb
@@ -0,0 +1,11 @@
+class Hash
+ # Returns a deep copy of hash.
+ def deep_dup
+ duplicate = self.dup
+ duplicate.each_pair do |k,v|
+ tv = duplicate[k]
+ duplicate[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? tv.deep_dup : v
+ end
+ duplicate
+ end
+end