Class: TypedOperation::FallbackChain
- Inherits:
-
ChainedOperation
- Object
- ChainedOperation
- TypedOperation::FallbackChain
- Defined in:
- lib/typed_operation/chains/fallback_chain.rb
Overview
Fallback chain created by .or_else Calls the fallback only when the left operation fails. Passes through success unchanged.
For blocks: passes the failure value. For operations: passes the original call arguments (so fallback can retry).
Instance Method Summary collapse
-
#call(*args, **kwargs) ⇒ Object
: (*untyped, **untyped) -> _Result[untyped, untyped].
Methods inherited from ChainedOperation
Methods included from Operations::Composition
#or_else, #then, #then_passes, #then_spreads, #transform
Constructor Details
This class inherits a constructor from TypedOperation::ChainedOperation
Instance Method Details
#call(*args, **kwargs) ⇒ Object
: (*untyped, **untyped) -> _Result[untyped, untyped]
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/typed_operation/chains/fallback_chain.rb', line 13 def call(*args, **kwargs) result = @left.call(*args, **kwargs) return result if result.success? if Instrumentation.tracing? Instrumentation.set_chain_context( pass_mode: :fallback, extracted_params: nil, fallback_used: true ) end if @right.is_a?(Proc) @right.call(result.failure) else @right.call(*args, **kwargs) end end |