Conditionally defining #blank? on String/NilClass
Signed-off-by: Chris Eppstein <chris@eppsteins.net>
This commit is contained in:
parent
3f16225556
commit
2c89b21f82
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user