提交 f5ce0f39 编写于 作者: R Ryuta Kamizono

Remove unnecessary `any?` and `many?` methods for collection proxy

Simply use its own methods because `CollectionProxy` inherits `Relation`.
上级 c1d612cf
......@@ -286,28 +286,6 @@ def empty?
end
end
# Returns true if the collections is not empty.
# If block given, loads all records and checks for one or more matches.
# Otherwise, equivalent to +!collection.empty?+.
def any?
if block_given?
load_target.any? { |*block_args| yield(*block_args) }
else
!empty?
end
end
# Returns true if the collection has more than 1 record.
# If block given, loads all records and checks for two or more matches.
# Otherwise, equivalent to +collection.size > 1+.
def many?
if block_given?
load_target.many? { |*block_args| yield(*block_args) }
else
size > 1
end
end
def distinct
seen = {}
load_target.find_all do |record|
......
......@@ -851,6 +851,12 @@ def empty?
@association.empty?
end
##
# :method: any?
#
# :call-seq:
# any?()
#
# Returns +true+ if the collection is not empty.
#
# class Person < ActiveRecord::Base
......@@ -880,10 +886,13 @@ def empty?
# pet.group == 'dogs'
# end
# # => true
def any?(&block)
@association.any?(&block)
end
##
# :method: many?
#
# :call-seq:
# many?()
#
# Returns true if the collection has more than one record.
# Equivalent to <tt>collection.size > 1</tt>.
#
......@@ -918,9 +927,6 @@ def any?(&block)
# pet.group == 'cats'
# end
# # => true
def many?(&block)
@association.many?(&block)
end
# Returns +true+ if the given +record+ is present in the collection.
#
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册