@@ -8,16 +8,13 @@ def self.Wrap(user_wrap, id: Macro.id_for(user_wrap, macro: :Wrap), &block)
88
99 outputs = Hash [ outputs . collect { |output | [ output . semantic , output ] } ] # FIXME: redundant to Subprocess().
1010
11- # Since in the user block, you can return Railway.pass! etc, we need to map
12- # those to the actual wrapped block_activity's end .
11+ # Since in the user block, you can return Railway.pass! etc, we need to translate
12+ # those to the actual block_activity's termini .
1313 signal_to_output = {
1414 Activity ::Right => outputs [ :success ] . signal ,
1515 Activity ::Left => outputs [ :failure ] . signal ,
1616 Activity ::FastTrack ::PassFast => outputs [ :pass_fast ] . signal ,
1717 Activity ::FastTrack ::FailFast => outputs [ :fail_fast ] . signal ,
18- true => outputs [ :success ] . signal ,
19- false => outputs [ :failure ] . signal ,
20- nil => outputs [ :failure ] . signal ,
2118 }
2219
2320 state = Declarative ::State (
@@ -45,31 +42,20 @@ def self.Wrap(user_wrap, id: Macro.id_for(user_wrap, macro: :Wrap), &block)
4542 class Wrap < Macro ::Strategy
4643 def self . call ( ctx , flow_options , circuit_options )
4744 # since yield is called without arguments, we need to pull default params from here. Oh ... tricky.
48-
4945 block_called_from_user_yield = -> ( ) { # DISCUSS: because we allow users to call {yield}, we don't receive any args here.
5046 Activity ::Circuit ::Runner . ( block_activity , ctx , flow_options , circuit_options )
5147 }
5248
53- # call the user's Wrap {} block in the operation.
54- # This will invoke block_called_from_user_yield above if the user block yields.
5549 user_handler = @state . get ( :user_wrap )
5650
5751 # Invoke the user's handler.
58- returned = user_handler . ( ctx , flow_options , circuit_options , &block_called_from_user_yield )
59-
60- # {returned} can be
61- # 1. {circuit interface return} from the begin block, because the wrapped OP passed
62- # 2. {task interface return} because the user block returns "customized" signals, true of fale
63-
64- if returned . is_a? ( Array ) # 1. {circuit interface return}, new style.
65- ctx , flow_options , signal = returned
66- else # 2. {task interface return}, only a signal (or true/false)
67- # TODO: deprecate this?
68- signal = returned
69- end
52+ ctx , flow_options , signal = user_handler . ( ctx , flow_options , circuit_options , &block_called_from_user_yield )
7053
71- # If there's no mapping, use the original {signal} .
72- # This usually means signal is a terminus or a custom signal.
54+ # The user handler is allowed to return signals like Right and Left. We need to translate
55+ # those to termini signals from the block_activity, cause those are the only ones
56+ # we route.
57+ # DISCUSS: i would love to skip this, but that'd mean the user has to return a
58+ # "native" signal from their block.
7359 signal = @state . get ( :signal_to_output ) . fetch ( signal , signal )
7460
7561 return ctx , flow_options , signal
0 commit comments