Class: Pipeable::Steps::Try
- Defined in:
- lib/pipeable/steps/try.rb
Overview
Sends a risky message to an object which may pass or fail.
Instance Method Summary collapse
- #call(result) ⇒ Object
-
#initialize(catch:) ⇒ Try
constructor
A new instance of Try.
Methods included from Composable
Constructor Details
#initialize(catch:) ⇒ Try
Returns a new instance of Try.
7 8 9 10 |
# File 'lib/pipeable/steps/try.rb', line 7 def initialize(*, catch:, **) super(*, **) @catch = catch end |
Instance Method Details
#call(result) ⇒ Object
12 13 14 15 16 |
# File 'lib/pipeable/steps/try.rb', line 12 def call result result.fmap { |object| object.public_send(*base_positionals, **base_keywords) } rescue *Array(catch) => error Failure error end |