aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/array
diff options
context:
space:
mode:
authorVasiliy Ermolovich <younash@gmail.com>2011-12-22 19:30:10 +0300
committerVasiliy Ermolovich <younash@gmail.com>2011-12-22 19:34:39 +0300
commitc4df2d0b6e0c1f4e0df4a66bfae91a684f3d9f71 (patch)
tree9546bca07bee905320ba12ca415d38e8ed4cd82b /activesupport/lib/active_support/core_ext/array
parentfa5adfb1e884bf21a7071ade634a820e37ac4db4 (diff)
downloadrails-c4df2d0b6e0c1f4e0df4a66bfae91a684f3d9f71.tar.gz
rails-c4df2d0b6e0c1f4e0df4a66bfae91a684f3d9f71.tar.bz2
rails-c4df2d0b6e0c1f4e0df4a66bfae91a684f3d9f71.zip
deprecate Array#uniq_by and Array#uniq_by! in favor of Array#uniq and Array#uniq! from ruby 1.9
Diffstat (limited to 'activesupport/lib/active_support/core_ext/array')
-rw-r--r--activesupport/lib/active_support/core_ext/array/uniq_by.rb14
1 files changed, 8 insertions, 6 deletions
diff --git a/activesupport/lib/active_support/core_ext/array/uniq_by.rb b/activesupport/lib/active_support/core_ext/array/uniq_by.rb
index 9c5f97b0e9..edc164dabd 100644
--- a/activesupport/lib/active_support/core_ext/array/uniq_by.rb
+++ b/activesupport/lib/active_support/core_ext/array/uniq_by.rb
@@ -3,14 +3,16 @@ class Array
#
# [1, 2, 3, 4].uniq_by { |i| i.odd? } # => [1, 2]
#
- def uniq_by
- hash, array = {}, []
- each { |i| hash[yield(i)] ||= (array << i) }
- array
+ def uniq_by(&block)
+ ActiveSupport::Deprecation.warn "uniq_by " \
+ "is deprecated. Use Array#uniq instead", caller
+ uniq(&block)
end
# Same as uniq_by, but modifies self.
- def uniq_by!
- replace(uniq_by{ |i| yield(i) })
+ def uniq_by!(&block)
+ ActiveSupport::Deprecation.warn "uniq_by! " \
+ "is deprecated. Use Array#uniq! instead", caller
+ uniq!(&block)
end
end