Permalink
Browse files

Merge [6793] to stable from trunk: document Object#blank?. References #…

…6491.

git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/1-2-stable@6794 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 6ba8d87 commit 788d4b0cc3a4f875b93cdeecae4b6e04edfef4b2 @jeremy jeremy committed May 20, 2007
Showing with 11 additions and 3 deletions.
  1. +2 −0 activesupport/CHANGELOG
  2. +9 −3 activesupport/lib/active_support/core_ext/blank.rb
View
@@ -1,5 +1,7 @@
*SVN*
+* Document Object#blank?. #6491 [Chris Mear]
+
* Update Dependencies to ignore constants inherited from ancestors. Closes #6951. [Nicholas Seckar]
* Improved multibyte performance by relying less on exception raising #8159 [Blaine]
@@ -1,5 +1,11 @@
-class Object #:nodoc:
- # "", " ", nil, [], and {} are blank
+class Object
+ # An object is blank if it's nil, empty, or a whitespace string.
+ # For example, "", " ", nil, [], and {} are blank.
+ #
+ # This simplifies
+ # if !address.nil? && !address.empty?
+ # to
+ # if !address.blank?
def blank?
if respond_to?(:empty?) && respond_to?(:strip)
empty? or strip.empty?
@@ -47,4 +53,4 @@ class Numeric #:nodoc:
def blank?
false
end
-end
+end

0 comments on commit 788d4b0

Please sign in to comment.