Module: Trailblazer::Activity::DSL::Linear::Normalizer::Inherit
- Defined in:
- lib/trailblazer/activity/dsl/linear/normalizer/inherit.rb
Overview
“generic”: built by the DSL from options, options that are inherited, so you might not want to record or inherit generic options
Defined Under Namespace
Classes: Record
Class Method Summary collapse
-
.compile_recorded_options(ctx, non_symbol_options:) ⇒ Object
Record Figure out what to remember from the options and store it in :recorded_options.
- .find_row(sequence, id) ⇒ Object
-
.recall_recorded_options(ctx, non_symbol_options:, sequence:, id:, inherit: nil, extensions: []) ⇒ Object
Currently, the :inherit option copies over :extensions from the original step and merges them with new :extensions.
- .Record(options, type:, non_symbol_options: true) ⇒ Object
Class Method Details
.compile_recorded_options(ctx, non_symbol_options:) ⇒ Object
Record Figure out what to remember from the options and store it in :recorded_options. Note that this is generic logic not tied to variable_mapping, OutputTuples or anything.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/trailblazer/activity/dsl/linear/normalizer/inherit.rb', line 70 def (ctx, non_symbol_options:, **) = {} .find_all { |k, v| k.instance_of?(Record) } .collect do |k, v| [k.type] = k # DISCUSS: we overwrite potential data with same type. end ctx.merge!( recorded_options: , # add {row.data[:recorded_options]} in Sequence: non_symbol_options: .merge(Strategy.DataVariable() => :recorded_options) ) end |
.find_row(sequence, id) ⇒ Object
62 63 64 65 |
# File 'lib/trailblazer/activity/dsl/linear/normalizer/inherit.rb', line 62 def find_row(sequence, id) index = Activity::Adds::Insert.find_index(sequence, id) sequence[index] end |
.recall_recorded_options(ctx, non_symbol_options:, sequence:, id:, inherit: nil, extensions: []) ⇒ Object
Currently, the :inherit option copies over :extensions from the original step and merges them with new :extensions.
Recall Fetch remembered options and add them to the processed options.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/trailblazer/activity/dsl/linear/normalizer/inherit.rb', line 26 def (ctx, non_symbol_options:, sequence:, id:, inherit: nil, extensions: [], **) return unless inherit === true || inherit.is_a?(Array) # E.g. {variable_mapping: true, wiring_api: true} types_to_recall = if inherit === true # we want to inherit "everything": extensions, output_tuples, variable_mapping Hash.new { true } else inherit.collect { |type| [type, true] }.to_h end row = find_row(sequence, id) # from this row we're inheriting options. # DISCUSS: should we maybe revert the idea of separating options by type? # Anyway, key idea here is that Record() users don't have to know these details # about symbol vs. non-symbol. = {} = {} row.data[:recorded_options].each do |type, record| next unless types_to_recall[type] target = record. ? : target.merge!(record.) end ctx[:non_symbol_options] = .merge() ctx.merge!() ctx.merge!( inherited_recorded_options: row.data[:recorded_options] ) end |
.Record(options, type:, non_symbol_options: true) ⇒ Object
18 19 20 |
# File 'lib/trailblazer/activity/dsl/linear/normalizer/inherit.rb', line 18 def Record(, type:, non_symbol_options: true) {Record.new(, type, ) => nil} end |