Class: Object

Inherits:
BasicObject
Defined in:
lib/backports/rails/kernel.rb

Instance Method Summary collapse

Instance Method Details

#try(*a, &b) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/backports/rails/kernel.rb', line 10

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