Class: Object

Inherits:
BasicObject
Defined in:
lib/aromat/try.rb

Overview

Monkey-patch Object Class

Instance Method Summary collapse

Instance Method Details

#try(meth, *args, &block) ⇒ Object

Try: Call a method if possible, do nothing otherwise.

Parameters:

  • meth (Symbol)

    Method name

  • args (Array)

    Method arguments

  • block (Object)

    Method block



12
13
14
15
# File 'lib/aromat/try.rb', line 12

def try meth, *args, &block
	return nil unless respond_to? meth
	send meth.to_sym, *args, &block
end