diff options
author | Marc-Andre Lafortune <github@marc-andre.ca> | 2011-07-23 15:38:55 -0400 |
---|---|---|
committer | Marc-Andre Lafortune <github@marc-andre.ca> | 2011-07-23 15:52:37 -0400 |
commit | a96e824c5388ed756685a041578688a7e14a8247 (patch) | |
tree | d3c4126222faf86fad8d479a0edd41072d075898 /activesupport/lib | |
parent | f6ac022a6fa7ac68106ef8a85f2ce9b2465ef6e2 (diff) | |
download | rails-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.rb | 4 |
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 |