Class: TypedOperation::MapChain

Inherits:
ChainedOperation show all
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

Methods inherited from ChainedOperation

#initialize

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

#callObject

: (*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