Froze rails gems
[depot.git] / vendor / rails / actionmailer / lib / action_mailer / vendor / tmail-1.2.3 / tmail / core_extensions.rb
1 #:stopdoc:
2 unless Object.respond_to?(:blank?)
3 class Object
4 # Check first to see if we are in a Rails environment, no need to
5 # define these methods if we are
6
7 # An object is blank if it's nil, empty, or a whitespace string.
8 # For example, "", " ", nil, [], and {} are blank.
9 #
10 # This simplifies
11 # if !address.nil? && !address.empty?
12 # to
13 # if !address.blank?
14 def blank?
15 if respond_to?(:empty?) && respond_to?(:strip)
16 empty? or strip.empty?
17 elsif respond_to?(:empty?)
18 empty?
19 else
20 !self
21 end
22 end
23 end
24
25 class NilClass
26 def blank?
27 true
28 end
29 end
30
31 class FalseClass
32 def blank?
33 true
34 end
35 end
36
37 class TrueClass
38 def blank?
39 false
40 end
41 end
42
43 class Array
44 alias_method :blank?, :empty?
45 end
46
47 class Hash
48 alias_method :blank?, :empty?
49 end
50
51 class String
52 def blank?
53 empty? || strip.empty?
54 end
55 end
56
57 class Numeric
58 def blank?
59 false
60 end
61 end
62 end
63 #:startdoc: