From 98553a5574a37f96b90acb8dcfa64b4c15a93de4 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Sun, 6 May 2012 11:12:54 -0700 Subject: Keep all methods in object/deep_dup --- activesupport/lib/active_support/core_ext/array.rb | 1 - .../lib/active_support/core_ext/array/deep_dup.rb | 6 ------ activesupport/lib/active_support/core_ext/hash.rb | 1 - .../lib/active_support/core_ext/hash/deep_dup.rb | 8 -------- .../lib/active_support/core_ext/object/deep_dup.rb | 16 ++++++++++++++++ activesupport/test/core_ext/deep_dup_test.rb | 3 +-- 6 files changed, 17 insertions(+), 18 deletions(-) delete mode 100644 activesupport/lib/active_support/core_ext/array/deep_dup.rb delete mode 100644 activesupport/lib/active_support/core_ext/hash/deep_dup.rb (limited to 'activesupport') diff --git a/activesupport/lib/active_support/core_ext/array.rb b/activesupport/lib/active_support/core_ext/array.rb index d6e1398a27..79ba79192a 100644 --- a/activesupport/lib/active_support/core_ext/array.rb +++ b/activesupport/lib/active_support/core_ext/array.rb @@ -1,7 +1,6 @@ require 'active_support/core_ext/array/wrap' require 'active_support/core_ext/array/access' require 'active_support/core_ext/array/uniq_by' -require 'active_support/core_ext/array/deep_dup' require 'active_support/core_ext/array/conversions' require 'active_support/core_ext/array/extract_options' require 'active_support/core_ext/array/grouping' diff --git a/activesupport/lib/active_support/core_ext/array/deep_dup.rb b/activesupport/lib/active_support/core_ext/array/deep_dup.rb deleted file mode 100644 index 82f9805236..0000000000 --- a/activesupport/lib/active_support/core_ext/array/deep_dup.rb +++ /dev/null @@ -1,6 +0,0 @@ -class Array - # Returns a deep copy of array. - def deep_dup - map { |it| it.deep_dup } - end -end diff --git a/activesupport/lib/active_support/core_ext/hash.rb b/activesupport/lib/active_support/core_ext/hash.rb index fd1cda991e..501483498d 100644 --- a/activesupport/lib/active_support/core_ext/hash.rb +++ b/activesupport/lib/active_support/core_ext/hash.rb @@ -1,6 +1,5 @@ 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 deleted file mode 100644 index 882f27623e..0000000000 --- a/activesupport/lib/active_support/core_ext/hash/deep_dup.rb +++ /dev/null @@ -1,8 +0,0 @@ -class Hash - # Returns a deep copy of hash. - def deep_dup - each_with_object(dup) do |(key, value), hash| - hash[key.deep_dup] = value.deep_dup - end - end -end diff --git a/activesupport/lib/active_support/core_ext/object/deep_dup.rb b/activesupport/lib/active_support/core_ext/object/deep_dup.rb index daae98dde1..2c4383ac94 100644 --- a/activesupport/lib/active_support/core_ext/object/deep_dup.rb +++ b/activesupport/lib/active_support/core_ext/object/deep_dup.rb @@ -4,3 +4,19 @@ class Object duplicable? ? dup : self end end + +class Array + # Returns a deep copy of array. + def deep_dup + map { |it| it.deep_dup } + end +end + +class Hash + # Returns a deep copy of hash. + def deep_dup + each_with_object(dup) do |(key, value), hash| + hash[key.deep_dup] = value.deep_dup + end + end +end diff --git a/activesupport/test/core_ext/deep_dup_test.rb b/activesupport/test/core_ext/deep_dup_test.rb index 2a00fc5315..91d558dbb5 100644 --- a/activesupport/test/core_ext/deep_dup_test.rb +++ b/activesupport/test/core_ext/deep_dup_test.rb @@ -1,6 +1,5 @@ +require 'abstract_unit' require 'active_support/core_ext/object' -require 'active_support/core_ext/array' -require 'active_support/core_ext/hash' class DeepDupTest < ActiveSupport::TestCase -- cgit v1.2.3