Class: Object

Inherits:
BasicObject
Defined in:
lib/webrat/core_extensions/blank.rb,
lib/webrat/core_extensions/meta_class.rb

Overview

:nodoc:

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?


12
13
14
# File 'lib/webrat/core_extensions/blank.rb', line 12

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

#meta_classObject



2
3
4
# File 'lib/webrat/core_extensions/meta_class.rb', line 2

def meta_class
  class << self; self end
end

#present?Boolean

An object is present if it's not blank.



17
18
19
# File 'lib/webrat/core_extensions/blank.rb', line 17

def present?
  !blank?
end