Class: TypedOperation::MapChain
- Inherits:
-
ChainedOperation
- Object
- ChainedOperation
- TypedOperation::MapChain
- Includes:
- Result::Mixin
- Defined in:
- lib/typed_operation/chains/map_chain.rb
Overview
Functor map chain created by .transform Block receives context, return value replaces context (wrapped in Success). Short-circuits on failure.
Instance Method Summary collapse
-
#call ⇒ 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 ⇒ Object
: (*untyped, **untyped) -> _Result[untyped, untyped]
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/typed_operation/chains/map_chain.rb', line 12 def call(...) result = @left.call(...) return result if result.failure? left_value = result.value! context = to_context(left_value) # Transform replaces context entirely (no merge) transformed = @right.call(context) Success(transformed) end |