aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2008-11-19 11:51:57 -0800
committerJeremy Kemper <jeremy@bitsweat.net>2008-11-19 11:51:57 -0800
commit7ee9addb6edc6d231ab5d95a24964a56b0b175d0 (patch)
tree2f307aca824f13ad15ee9624eded244ff87b2928 /activesupport
parent5b7d07f4231a20e6517ca8fd7beab23e56cf81db (diff)
downloadrails-7ee9addb6edc6d231ab5d95a24964a56b0b175d0.tar.gz
rails-7ee9addb6edc6d231ab5d95a24964a56b0b175d0.tar.bz2
rails-7ee9addb6edc6d231ab5d95a24964a56b0b175d0.zip
Enumerable#none? conforms to Ruby 1.8.7 behavior
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/core_ext/enumerable.rb6
-rw-r--r--activesupport/test/core_ext/enumerable_test.rb3
2 files changed, 5 insertions, 4 deletions
diff --git a/activesupport/lib/active_support/core_ext/enumerable.rb b/activesupport/lib/active_support/core_ext/enumerable.rb
index 26596d838d..a7eaccfed7 100644
--- a/activesupport/lib/active_support/core_ext/enumerable.rb
+++ b/activesupport/lib/active_support/core_ext/enumerable.rb
@@ -106,11 +106,11 @@ module Enumerable
end
# Returns true if none of the elements match the given block.
- #
+ #
# success = responses.none? {|r| r.status / 100 == 5 }
#
+ # This is a builtin method in Ruby 1.8.7 and later.
def none?(&block)
- return true if !block_given? || blank?
!any?(&block)
- end
+ end unless [].respond_to?(:none?)
end
diff --git a/activesupport/test/core_ext/enumerable_test.rb b/activesupport/test/core_ext/enumerable_test.rb
index 288ce14b2c..92db977a77 100644
--- a/activesupport/test/core_ext/enumerable_test.rb
+++ b/activesupport/test/core_ext/enumerable_test.rb
@@ -82,7 +82,8 @@ class EnumerableTests < Test::Unit::TestCase
def test_none
assert [].none?
- assert [ 1 ].none?
+ assert [nil, false].none?
+ assert ![1].none?
assert [].none? {|x| x > 1 }
assert ![ 2 ].none? {|x| x > 1 }