Class: Object

Inherits:
BasicObject
Defined in:
lib/alpha_card/object.rb

Instance Method Summary collapse

Instance Method Details

#blank?Boolean

Returns:

  • (Boolean)


2
3
4
# File 'lib/alpha_card/object.rb', line 2

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

#present?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/alpha_card/object.rb', line 6

def present?
  !blank?
end

#try(*a, &b) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/alpha_card/object.rb', line 10

def try(*a, &b)
  if a.empty? && block_given?
    yield self
  else
    public_send(*a, &b) if respond_to?(a.first)
  end
end