Class: Object

Inherits:
BasicObject
Defined in:
lib/object.rb

Instance Method Summary collapse

Instance Method Details

#present?Boolean

Returns:

  • (Boolean)


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

def present?
  ! nil?
end

#to_aObject



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

def to_a
  [ self ]
end

#try(method_name = nil, *args, &b) ⇒ Object

stolen from activesupport core extensions



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

def try( method_name = nil, *args, &b )
  if method_name.nil? && block_given?
    b.arity == 0 ? instance_eval( &b ) : yield( self )
  elsif respond_to?( method_name )
    public_send( method_name, *args, &b )
  end
end