Module: Dux::Attempt

Extended by:
Attempt
Included in:
Dux, Attempt
Defined in:
lib/dux/attempt.rb

Overview

Object#try for when you don't want ActiveSupport

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.attempt(receiver, method, *args, &block) ⇒ Object?

Parameters:

Returns:



9
10
11
# File 'lib/dux/attempt.rb', line 9

def attempt(receiver, method, *args, &block)
  receiver.public_send(method, *args, &block) if receiver.respond_to?(method)
end

Instance Method Details

#attempt(receiver, method, *args, &block) ⇒ Object?

Parameters:

Returns:



9
10
11
# File 'lib/dux/attempt.rb', line 9

def attempt(receiver, method, *args, &block)
  receiver.public_send(method, *args, &block) if receiver.respond_to?(method)
end