From a96e824c5388ed756685a041578688a7e14a8247 Mon Sep 17 00:00:00 2001 From: Marc-Andre Lafortune Date: Sat, 23 Jul 2011 15:38:55 -0400 Subject: Make Enumerable#many? not rely on #size --- activesupport/lib/active_support/core_ext/enumerable.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activesupport/lib/active_support/core_ext') diff --git a/activesupport/lib/active_support/core_ext/enumerable.rb b/activesupport/lib/active_support/core_ext/enumerable.rb index 3e05c6eaf2..9b835aab9e 100644 --- a/activesupport/lib/active_support/core_ext/enumerable.rb +++ b/activesupport/lib/active_support/core_ext/enumerable.rb @@ -93,10 +93,10 @@ module Enumerable Hash[map { |elem| [yield(elem), elem] }] end - # Returns true if the collection has more than 1 element. Functionally equivalent to collection.size > 1. + # Returns true if the enumerable has more than 1 element. Functionally equivalent to enum.to_a.size > 1. # Can be called with a block too, much like any?, so people.many? { |p| p.age > 26 } returns true if more than 1 person is over 26. def many?(&block) - size = block_given? ? count(&block) : self.size + size = block_given? ? count(&block) : to_a.size size > 1 end -- cgit v1.2.3