aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/array/uniq_by.rb
blob: ac3dedc0e306be372e47831edad00f9dcfa2b373 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
class Array
  # *DEPRECATED*: Use +Array#uniq+ instead.
  #
  # Returns a unique array based on the criteria in the block.
  #
  #   [1, 2, 3, 4].uniq_by { |i| i.odd? } # => [1, 2]
  #
  def uniq_by(&block)
    ActiveSupport::Deprecation.warn "uniq_by " \
      "is deprecated. Use Array#uniq instead", caller
    uniq(&block)
  end

  # *DEPRECATED*: Use +Array#uniq!+ instead.
  #
  # Same as +uniq_by+, but modifies +self+.
  def uniq_by!(&block)
    ActiveSupport::Deprecation.warn "uniq_by! " \
      "is deprecated. Use Array#uniq! instead", caller
    uniq!(&block)
  end
end