Skip to content

Instantly share code, notes, and snippets.

@teebu
Created March 10, 2016 07:20
Show Gist options
  • Save teebu/3cba0ef79b51f7d7e75a to your computer and use it in GitHub Desktop.
Save teebu/3cba0ef79b51f7d7e75a to your computer and use it in GitHub Desktop.
class NilClass
def blank?
true
end
def not_blank?
!blank?
end
end
class String
def blank?
self.strip.empty?
end
def not_blank?
!blank?
end
end
class FalseClass
def blank?
true
end
def not_blank?
!blank?
end
end
class TrueClass
def blank?
false
end
def not_blank?
!blank?
end
end
class Object
def blank?
respond_to?(:empty?) ? empty? : !self
end
def not_blank?
!blank?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment