aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorMarc-Andre Lafortune <github@marc-andre.ca>2011-07-23 15:38:55 -0400
committerMarc-Andre Lafortune <github@marc-andre.ca>2011-07-23 15:52:37 -0400
commita96e824c5388ed756685a041578688a7e14a8247 (patch)
treed3c4126222faf86fad8d479a0edd41072d075898 /activesupport/lib
parentf6ac022a6fa7ac68106ef8a85f2ce9b2465ef6e2 (diff)
downloadrails-a96e824c5388ed756685a041578688a7e14a8247.tar.gz
rails-a96e824c5388ed756685a041578688a7e14a8247.tar.bz2
rails-a96e824c5388ed756685a041578688a7e14a8247.zip
Make Enumerable#many? not rely on #size
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/core_ext/enumerable.rb4
1 files changed, 2 insertions, 2 deletions
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