Class: TypedOperation::SplatChain

Inherits:
ChainedOperation show all
Includes:
Result::Mixin
Defined in:
lib/typed_operation/chains/splat_chain.rb

Overview

Kwargs spreading chain created by .then_spreads Always splats the full context as **kwargs to the next operation. Accumulates result into context.

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
23
24
25
26
27
# File 'lib/typed_operation/chains/splat_chain.rb', line 12

def call(...)
  result = @left.call(...)
  return result if result.failure?

  left_value = result.value!
  context = to_context(left_value)

  right_result = @right.call(**context)
  return right_result if right_result.failure?

  # Merge right's output into context
  right_value = right_result.value!
  merged = merge_into_context(context, right_value)

  Success(merged)
end