Merge pull request #2032 from dziulius/master

#many? - uses count instead of select
This commit is contained in:
Xavier Noria 2011-07-11 08:36:15 -07:00
commit 91bba21815

@ -96,7 +96,7 @@ def index_by
# Returns true if the collection has more than 1 element. Functionally equivalent to collection.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? ? select(&block).size : self.size
size = block_given? ? count(&block) : self.size
size > 1
end