Module: Trailblazer::Activity::DSL::Linear::Strategy

Extended by:
Forwardable
Included in:
FastTrack, Path, Railway
Defined in:
lib/trailblazer/activity/dsl/linear/strategy.rb

Overview

Trailblazer::Activity

holds the {@schema}
provides DSL step/merge!
provides DSL inheritance
provides run-time {call}
maintains the {state} with {seq} and normalizer options

Defined Under Namespace

Classes: BlockProxy

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.task_for!(state, type, task, options = {}, &block) ⇒ Object

Called from #step and friends.



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/trailblazer/activity/dsl/linear/strategy.rb', line 28

def self.task_for!(state, type, task, options={}, &block)
  options = options.merge(dsl_track: type)

  # {#update_sequence} is the only way to mutate the state instance.
  state.update_sequence do |sequence:, normalizers:, normalizer_options:|
    # Compute the sequence rows.
    options = normalizers.(type, normalizer_options: normalizer_options, options: task, user_options: options.merge(sequence: sequence))

    sequence = Activity::DSL::Linear::DSL.apply_adds_from_dsl(sequence, options)
  end
end

Instance Method Details

#call(args, circuit_options = {}) ⇒ Object

Injects :exec_context so that :instance_methods work.



93
94
95
96
97
98
# File 'lib/trailblazer/activity/dsl/linear/strategy.rb', line 93

def call(args, circuit_options={})
  @activity.(
    args,
    circuit_options.merge(exec_context: new)
  )
end

#inherited(inheriter) ⇒ Object



20
21
22
23
24
25
# File 'lib/trailblazer/activity/dsl/linear/strategy.rb', line 20

def inherited(inheriter)
  super

  # inherits the {@sequence}, and options.
  inheriter.initialize!(@state.copy)
end

#initialize!(state) ⇒ Object



14
15
16
17
18
# File 'lib/trailblazer/activity/dsl/linear/strategy.rb', line 14

def initialize!(state)
  @state    = state

  recompile_activity!(@state.to_h[:sequence])
end

#invoke(*args) ⇒ Object



100
101
102
# File 'lib/trailblazer/activity/dsl/linear/strategy.rb', line 100

def invoke(*args)
  TaskWrap.invoke(self, *args)
end

#Path(options) ⇒ Object

we can’t access block here, syntactically.



73
74
75
# File 'lib/trailblazer/activity/dsl/linear/strategy.rb', line 73

def Path(options) # we can't access {block} here, syntactically.
  BlockProxy.new(options)
end

#to_hObject



88
89
90
# File 'lib/trailblazer/activity/dsl/linear/strategy.rb', line 88

def to_h
  @activity.to_h.to_h.merge(activity: @activity)
end