Class: Object

Inherits:
BasicObject
Defined in:
lib/partigirb/core_ext.rb

Instance Method Summary collapse

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?

Returns:

  • (Boolean)


32
33
34
# File 'lib/partigirb/core_ext.rb', line 32

def blank?
  respond_to?(:empty?) ? empty? : !self
end

#present?Boolean

An object is present if it’s not blank.

Returns:

  • (Boolean)


37
38
39
# File 'lib/partigirb/core_ext.rb', line 37

def present?
  !blank?
end