class Object

github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/object/try.rb

Constants

LIB

Public Instance Methods

try(*a, &b) click to toggle source
# File lib/dayone-kindle.rb, line 6
def try(*a, &b)
  try!(*a, &b) if a.empty? || respond_to?(a.first)
end
try!(*a) { |self| ... } click to toggle source
# File lib/dayone-kindle.rb, line 10
def try!(*a, &b)
  if a.empty? && block_given?
    if b.arity == 0
      instance_eval(&b)
    else
      yield self
    end
  else
    public_send(*a, &b)
  end
end