Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 57 lines (47 sloc) 0.762 kb
9718769 Updated the sponsors and contact page.
Tom Henrik Aadland authored
1 # I stole these from rails core_ext
2
3 class Object
4 # An object is blank if it's false, empty, or a whitespace string.
5 # For example, "", " ", +nil+, [], and {} are blank.
6 #
7 # This simplifies
8 #
9 # if !address.nil? && !address.empty?
10 #
11 # to
12 #
13 # if !address.blank?
14 def blank?
15 respond_to?(:empty?) ? empty? : !self
16 end
17 end
18
19 class NilClass #:nodoc:
20 def blank?
21 true
22 end
23 end
24
25 class FalseClass #:nodoc:
26 def blank?
27 true
28 end
29 end
30
31 class TrueClass #:nodoc:
32 def blank?
33 false
34 end
35 end
36
37 class Array #:nodoc:
38 alias_method :blank?, :empty?
39 end
40
41 class Hash #:nodoc:
42 alias_method :blank?, :empty?
43 end
44
45 class String #:nodoc:
46 def blank?
47 self !~ /\S/
48 end
49 end
50
51 class Numeric #:nodoc:
52 def blank?
53 false
54 end
55 end
56
Something went wrong with that request. Please try again.