Class: Object

Inherits:
BasicObject
Defined in:
lib/mobility/core_ext/object.rb

Overview

Add blank?, present? and presence methods to Object class if activesupport cannot be loaded.

Instance Method Summary collapse

Instance Method Details

#blank?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/mobility/core_ext/object.rb', line 8

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

#presenceObject



16
17
18
# File 'lib/mobility/core_ext/object.rb', line 16

def presence
  self if present?
end

#present?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/mobility/core_ext/object.rb', line 12

def present?
  !blank?
end