Module: Trailblazer::Activity::DSL::Linear::VariableMapping
- Defined in:
- lib/trailblazer/activity/dsl/linear/feature/variable_mapping.rb,
lib/trailblazer/activity/dsl/linear/feature/variable_mapping/dsl.rb,
lib/trailblazer/activity/dsl/linear/feature/variable_mapping/runtime.rb
Defined Under Namespace
Modules: DSL, Normalizer, Pipe Classes: AddVariables, SetVariable, VariableFromCtx, VariablePresent
Class Method Summary collapse
-
.default_input_ctx(wrap_ctx, original_args) ⇒ Object
Merge all original ctx variables into the new input_ctx.
-
.default_output_ctx(wrap_ctx, original_args) ⇒ Object
The default :output filter only returns the “mutable” part of the inner ctx.
- .deprecation_link ⇒ Object
-
.extend!(strategy, *step_methods) ⇒ Object
Add our normalizer steps to the strategy’s normalizer.
- .Extension(input, output, input_id: "task_wrap.input", output_id: "task_wrap.output") ⇒ Object
-
.merge_instructions_from_dsl(**options) ⇒ Object
For the input filter we 1.
- .merge_variables(variables, wrap_ctx, original_args, receiver = ) ⇒ Object
- .merge_with_original(wrap_ctx, original_args) ⇒ Object
-
.scope(wrap_ctx, original_args) ⇒ Object
Finally, create a new input ctx from all the collected input variables.
Class Method Details
.default_input_ctx(wrap_ctx, original_args) ⇒ Object
Merge all original ctx variables into the new input_ctx. This happens when no :input is provided.
54 55 56 57 58 |
# File 'lib/trailblazer/activity/dsl/linear/feature/variable_mapping/runtime.rb', line 54 def default_input_ctx(wrap_ctx, original_args) default_ctx = wrap_ctx[:original_ctx] merge_variables(default_ctx, wrap_ctx, original_args) end |
.default_output_ctx(wrap_ctx, original_args) ⇒ Object
The default :output filter only returns the “mutable” part of the inner ctx. This means only variables added using = are merged on the outside.
259 260 261 262 263 264 265 |
# File 'lib/trailblazer/activity/dsl/linear/feature/variable_mapping/runtime.rb', line 259 def default_output_ctx(wrap_ctx, original_args) new_ctx = wrap_ctx[:returned_ctx] _wrapped, mutable = new_ctx.decompose # `_wrapped` is what the `:input` filter returned, `mutable` is what the task wrote to `scoped`. merge_variables(mutable, wrap_ctx, original_args) end |
.deprecation_link ⇒ Object
135 136 137 |
# File 'lib/trailblazer/activity/dsl/linear/feature/variable_mapping.rb', line 135 def deprecation_link %(Please refer to https://trailblazer.to/2.1/docs/activity.html#activity-variable-mapping-deprecation-notes and have a nice day.) end |
.extend!(strategy, *step_methods) ⇒ Object
Add our normalizer steps to the strategy’s normalizer.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/trailblazer/activity/dsl/linear/feature/variable_mapping.rb', line 16 def self.extend!(strategy, *step_methods) # DISCUSS: should this be implemented in Linear? Linear::Normalizer.extend!(strategy, *step_methods) do |normalizer| Linear::Normalizer.prepend_to( normalizer, "activity.wirings", { # In(), Out(), {:input}, Inject() feature "activity.convert_symbol_options" => Linear::Normalizer.Task(VariableMapping::Normalizer.method(:convert_symbol_options)), "activity.normalize_input_output_filters" => Linear::Normalizer.Task(VariableMapping::Normalizer.method(:normalize_input_output_filters)), "activity.input_output_dsl" => Linear::Normalizer.Task(VariableMapping::Normalizer.method(:input_output_dsl)), } ) end end |
.Extension(input, output, input_id: "task_wrap.input", output_id: "task_wrap.output") ⇒ Object
31 32 33 34 35 36 |
# File 'lib/trailblazer/activity/dsl/linear/feature/variable_mapping.rb', line 31 def self.Extension(input, output, input_id: "task_wrap.input", output_id: "task_wrap.output") TaskWrap.Extension( [input, id: input_id, prepend: "task_wrap.call_task"], [output, id: output_id, append: "task_wrap.call_task"] ) end |
.merge_instructions_from_dsl(**options) ⇒ Object
For the input filter we
1. create a separate {Pipeline} instance {pipe}. Depending on the user's options, this might have up to four steps.
2. The {pipe} is run in a lamdba {input}, the lambda returns the pipe's ctx[:input_ctx].
3. The {input} filter in turn is wrapped into an {Activity::TaskWrap::Input} object via {#merge_instructions_for}.
4. The {TaskWrap::Input} instance is then finally placed into the taskWrap as {"task_wrap.input"}.
125 126 127 128 129 130 131 132 133 |
# File 'lib/trailblazer/activity/dsl/linear/feature/variable_mapping.rb', line 125 def merge_instructions_from_dsl(**) pipeline = DSL.pipe_for_composable_input(**) # FIXME: rename filters consistently input = Pipe::Input.new(pipeline) output_pipeline = DSL.pipe_for_composable_output(**) output = Pipe::Output.new(output_pipeline) return input, output end |
.merge_variables(variables, wrap_ctx, original_args, receiver = ) ⇒ Object
234 235 236 237 238 |
# File 'lib/trailblazer/activity/dsl/linear/feature/variable_mapping/runtime.rb', line 234 def merge_variables(variables, wrap_ctx, original_args, receiver = wrap_ctx[:aggregate]) wrap_ctx[:aggregate] = receiver.merge(variables) return wrap_ctx, original_args end |
.merge_with_original(wrap_ctx, original_args) ⇒ Object
267 268 269 270 271 272 |
# File 'lib/trailblazer/activity/dsl/linear/feature/variable_mapping/runtime.rb', line 267 def merge_with_original(wrap_ctx, original_args) original_ctx = wrap_ctx[:original_ctx] # outer ctx output_variables = wrap_ctx[:aggregate] merge_variables(output_variables, wrap_ctx, original_args, original_ctx) end |
.scope(wrap_ctx, original_args) ⇒ Object
Finally, create a new input ctx from all the collected input variables. This goes into the step/nested OP.
243 244 245 246 247 248 249 250 251 252 253 254 |
# File 'lib/trailblazer/activity/dsl/linear/feature/variable_mapping/runtime.rb', line 243 def scope(wrap_ctx, original_args) ((_, ), _) = original_args # this is the actual context passed into the step. wrap_ctx[:input_ctx] = Trailblazer::Context( wrap_ctx[:aggregate], {}, # mutable variables [:context_options] ) return wrap_ctx, original_args end |