Module: ActiveSupport::Tryable
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 'activesupport/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 'activesupport/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 |