From eb300f842864358c1b3b2809e4bbbe5af0f2eb33 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Tue, 5 Dec 2006 21:49:36 +0000 Subject: AssociationCollection#any? takes a block [Michael Schoen] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5681 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../lib/active_record/associations/association_collection.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb index b8337fe4d9..66b4079f55 100644 --- a/activerecord/lib/active_record/associations/association_collection.rb +++ b/activerecord/lib/active_record/associations/association_collection.rb @@ -116,9 +116,13 @@ module ActiveRecord def empty? size.zero? end - - def any? - !empty? + + def any?(&block) + if block_given? + method_missing(:any?, &block) + else + !empty? + end end def uniq(collection = self) -- cgit v1.2.3