Class: Object

Inherits:
BasicObject
Defined in:
lib/chain_try/ext/object.rb

Instance Method Summary collapse

Instance Method Details

#chain_try(*methods) ⇒ Object



2
3
4
5
6
7
8
9
10
# File 'lib/chain_try/ext/object.rb', line 2

def chain_try(*methods)
  result = self

  while method = methods.shift
    result = result.try(method.to_sym)
  end

  result
end