Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/importex/core_ext/blank.rb
Overview
Stolen straight from active_support/core_ext/object/blank.rb
Instance Method Summary collapse
-
#blank? ⇒ Boolean
An object is blank if it’s false, empty, or a whitespace string.
-
#present? ⇒ Boolean
An object is present if it’s not blank.
Instance Method Details
#blank? ⇒ Boolean
An object is blank if it’s false, empty, or a whitespace string. For example, “”, “ ”, nil
, [], and {} are blank.
This simplifies
if !address.nil? && !address.empty?
to
if !address.blank?
13 14 15 |
# File 'lib/importex/core_ext/blank.rb', line 13 def blank? respond_to?(:empty?) ? empty? : !self end |
#present? ⇒ Boolean
An object is present if it’s not blank.
18 19 20 |
# File 'lib/importex/core_ext/blank.rb', line 18 def present? !blank? end |