@@ -161,8 +161,22 @@ def my_model_input(ctx, params:, **)
161161 end
162162
163163 class IO___
164+ def init_aggregate ( ctx , **)
165+ ctx [ :aggregate ] = { }
166+
167+ return ctx , nil
168+ end
169+
164170 def add_value_to_aggregate ( ctx , aggregate :, value :, **)
165- ctx [ :aggregate ] = aggregate . merge! ( value )
171+ ctx [ :aggregate ] = aggregate . merge ( value )
172+ end
173+
174+ def unscope___ ( ctx , application_ctx :, aggregate :, **)
175+ original , _ = ctx . decompose
176+
177+ ctx = original . merge ( application_ctx : aggregate )
178+
179+ return ctx , nil
166180 end
167181 end
168182 Io = IO___ . new
@@ -175,9 +189,39 @@ def add_value_to_aggregate(ctx, aggregate:, value:, **)
175189 [ :add_value_to_aggregate , :add_value_to_aggregate , INVOKER___STEP_INTERFACE_ON_EXEC_CONTEXT , { exec_context : Io , use_application_ctx___ : false } ] ,
176190 # [:output, Model___Output],
177191 )
192+ # In() => MoreModelInput
193+ class MoreModelInput
194+ def self . call ( ctx , params :, **)
195+ {
196+ more : params . inspect
197+ }
198+ end
199+ end
200+ more_model_input_pipe = pipeline_circuit (
201+ # [:input, Model___Input], # DISCUSS: can we somehow save these steps?
202+ [ :invoke_callable , MoreModelInput , INVOKER___STEP_INTERFACE ] ,
203+ # [:compute_binary_signal, ComputeBinarySignal],
204+ [ :add_value_to_aggregate , :add_value_to_aggregate , INVOKER___STEP_INTERFACE_ON_EXEC_CONTEXT , { exec_context : Io , use_application_ctx___ : false } ] ,
205+ # [:output, Model___Output],
206+ )
207+
208+ model_input_pipe = pipeline_circuit (
209+ [ :scope , Model___Input ] , # scope
210+ [ :init_aggregate , :init_aggregate , INVOKER___CIRCUIT_INTERFACE_ON_EXEC_CONTEXT , { exec_context : Io } ] ,
211+ [ :my_model_input , my_model_input_pipe , Circuit ::Processor ] ,
212+ [ :more_model_input , more_model_input_pipe , Circuit ::Processor ] ,
213+ [ :unscope , :unscope___ , INVOKER___CIRCUIT_INTERFACE_ON_EXEC_CONTEXT , { exec_context : Io } ]
214+ )
215+
216+ ctx , signal = Circuit ::Processor . ( model_input_pipe , {
217+ application_ctx : { params : { id : 999 } } ,
218+ exec_context : create_instance = Create . new ,
219+ } )
178220
179- # ctx, signal = Circuit::Processor.(my_model_input_pipe, {application_ctx: {params: {}}, exec_context: Create.new} )
221+ # ctx, signal = Circuit::Processor.(more_model_input_pipe, ctx )
180222
223+ assert_equal ctx . inspect , %({:application_ctx=>{:params=>{:id=>"999"}, :more=>"{:id=>999}"}, :exec_context=>#{ create_instance } })
224+ pp ctx
181225
182226
183227
0 commit comments