Conditionally defining #blank? on String/NilClass

Signed-off-by: Chris Eppstein <chris@eppsteins.net>
This commit is contained in:
Erik Bryn 2009-04-17 02:29:55 +08:00 committed by Chris Eppstein
parent 3f16225556
commit 2c89b21f82

View File

@ -1,12 +1,14 @@
class String
# see if string has any content
def blank?; self.length.zero?; end
unless method_defined?(:blank?)
# see if string has any content
def blank?; self.length.zero?; end
end
end
class NilClass
def blank?
true
unless method_defined?(:blank?)
def blank?
true
end
end
end