Module: ActiveSupport::Tryable

Included in:
Delegator, Object
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/core_ext/object/try.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#try(*args, &block) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/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

#try!(*args, &block) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/core_ext/object/try.rb', line 20

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