public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Added Object#present? which is equivalent to !Object#blank? [DHH]
dhh (author)
Thu Jun 12 16:30:56 -0700 2008
commit  a3caf28da3a22c1326d3d98dcf71483a8edaa55a
tree    ffdee041bedbc1d57eba9cd3dcd4b0879a305158
parent  ea3a7e1bb1efc8b3ca10c4163bc116f3d5e23af1
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 *Edge*
0
 
0
+* Added Object#present? which is equivalent to !Object#blank? [DHH]
0
+
0
 * Added Enumberable#several? to encapsulate collection.size > 1 [DHH]
0
 
0
 * Add more standard Hash methods to ActiveSupport::OrderedHash [Steve Purcell]
...
12
13
14
 
 
 
 
 
15
16
17
...
12
13
14
15
16
17
18
19
20
21
22
0
@@ -12,6 +12,11 @@ class Object
0
   def blank?
0
     respond_to?(:empty?) ? empty? : !self
0
   end
0
+
0
+ # An object is present if it's not blank.
0
+ def present?
0
+ !blank?
0
+ end
0
 end
0
 
0
 class NilClass #:nodoc:
...
16
17
18
 
 
 
 
 
19
...
16
17
18
19
20
21
22
23
24
0
@@ -16,4 +16,9 @@ class BlankTest < Test::Unit::TestCase
0
     BLANK.each { |v| assert v.blank?, "#{v.inspect} should be blank" }
0
     NOT.each { |v| assert !v.blank?, "#{v.inspect} should not be blank" }
0
   end
0
+
0
+ def test_present
0
+ BLANK.each { |v| assert !v.present?, "#{v.inspect} should not be present" }
0
+ NOT.each { |v| assert v.present?, "#{v.inspect} should be present" }
0
+ end
0
 end

Comments

    No one has commented yet.