diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2006-12-05 21:49:36 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2006-12-05 21:49:36 +0000 |
commit | eb300f842864358c1b3b2809e4bbbe5af0f2eb33 (patch) | |
tree | c78278382184fbcc1838ca1476afc252dcb463f0 /activerecord/lib | |
parent | 7370e54cc4d6b298a29383bf943b277bcfb730aa (diff) | |
download | rails-eb300f842864358c1b3b2809e4bbbe5af0f2eb33.tar.gz rails-eb300f842864358c1b3b2809e4bbbe5af0f2eb33.tar.bz2 rails-eb300f842864358c1b3b2809e4bbbe5af0f2eb33.zip |
AssociationCollection#any? takes a block [Michael Schoen]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5681 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations/association_collection.rb | 10 |
1 files changed, 7 insertions, 3 deletions
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) |