6873fc8026
Upgraded to Rails 2.0.2, except that we maintain vendor/rails/actionpack/lib/action_controller/routing.rb from Rail 1.2.6 (at least for now), so that Routes don't change. We still get to enjoy Rails's many new features. Also fixed a bug in Chunk-handling: disable WikiWord processing in tags (for real this time).
51 lines
708 B
Ruby
51 lines
708 B
Ruby
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?
|
|
respond_to?(:empty?) ? empty? : !self
|
|
end
|
|
end
|
|
|
|
class NilClass #:nodoc:
|
|
def blank?
|
|
true
|
|
end
|
|
end
|
|
|
|
class FalseClass #:nodoc:
|
|
def blank?
|
|
true
|
|
end
|
|
end
|
|
|
|
class TrueClass #:nodoc:
|
|
def blank?
|
|
false
|
|
end
|
|
end
|
|
|
|
class Array #:nodoc:
|
|
alias_method :blank?, :empty?
|
|
end
|
|
|
|
class Hash #:nodoc:
|
|
alias_method :blank?, :empty?
|
|
end
|
|
|
|
class String #:nodoc:
|
|
def blank?
|
|
self !~ /\S/
|
|
end
|
|
end
|
|
|
|
class Numeric #:nodoc:
|
|
def blank?
|
|
false
|
|
end
|
|
end
|