Module: Trailblazer::Activity::DSL::Linear::Normalizer::Extensions

Defined in:
lib/trailblazer/activity/dsl/linear/normalizer/extensions.rb

Overview

Implements :extensions option and allows adding taskWrap extensions using Linear::Normalizer::Extensions.Extension().

Defined Under Namespace

Classes: Extension

Class Method Summary collapse

Class Method Details

.compile_extensions(ctx, non_symbol_options:) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/trailblazer/activity/dsl/linear/normalizer/extensions.rb', line 30

def compile_extensions(ctx, non_symbol_options:, **)
  extensions_ary =
    non_symbol_options
      .find_all { |k, v| k.instance_of?(Extension) }
      .to_h
      .values

  ctx.merge!(
    extensions: extensions_ary
  )
end

.compile_recorded_extensions(ctx, non_symbol_options:) ⇒ Object

Don’t record Extension()s created by the DSL! This happens in VariableMapping, for instance. Either the user also inherits I/O tuples and the extension will be recreated, or they really don’t want this particular extension to be inherited.



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/trailblazer/activity/dsl/linear/normalizer/extensions.rb', line 45

def compile_recorded_extensions(ctx, non_symbol_options:, **)
  recorded_extension_tuples =
    non_symbol_options
      .find_all { |k, v| k.instance_of?(Extension) }
      .reject   { |k, v| k.generic? }
      .to_h

  ctx.merge!(
    non_symbol_options: non_symbol_options.merge(
      Normalizer::Inherit.Record(recorded_extension_tuples, type: :extensions)
    )
  )
end

.convert_extensions_option_to_tuples(ctx, non_symbol_options:, extensions: nil) ⇒ Object

Convert :extensions option to Extension tuples. The new way of adding extensions is

step ..., Extension() => my_extension


19
20
21
22
23
24
25
26
27
28
# File 'lib/trailblazer/activity/dsl/linear/normalizer/extensions.rb', line 19

def convert_extensions_option_to_tuples(ctx, non_symbol_options:, extensions: nil, **)
  return unless extensions
  # TODO: deprecate {:extensions} in the DSL?

  extensions_tuples = extensions.collect { |ext| [Extension(), ext] }.to_h

  ctx.merge!(
    non_symbol_options: non_symbol_options.merge(extensions_tuples)
  )
end

.Extension(is_generic: false) ⇒ Object



13
14
15
# File 'lib/trailblazer/activity/dsl/linear/normalizer/extensions.rb', line 13

def Extension(is_generic: false)
  Extension.new(is_generic, rand) # {id} has to be unique for every Extension instance (for Hash identity).
end