class Object

Public Instance Methods

try_call(*args) click to toggle source

Many times an option can either be a callable object (Proc/Lambda) or not (symbol/string/integer). This will call with the included arguments, if it is callable, or return the object if not.

# File lib/core_ext/object.rb, line 5
def try_call(*args)
  if respond_to? :call
    call(*args)
  else
    self
  end
end