Method: ActiveSupport::Tryable#try

Defined in:
lib/active_support/core_ext/object/try.rb

#try(*args, &block) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/active_support/core_ext/object/try.rb', line 7

def try(*args, &block)
  if args.empty? && block_given?
    if block.arity == 0
      instance_eval(&block)
    else
      yield self
    end
  elsif respond_to?(args.first)
    public_send(*args, &block)
  end
end