class Flows::SharedContextPipeline::TrackList

@api private

Attributes

current_track[R]

Public Class Methods

new() click to toggle source
# File lib/flows/shared_context_pipeline/track_list.rb, line 7
def initialize
  @tracks = { main: Track.new(:main) }
  @current_track = :main
end

Public Instance Methods

add_step(step) click to toggle source
# File lib/flows/shared_context_pipeline/track_list.rb, line 21
def add_step(step)
  @tracks[@current_track].add_step(step)
end
first_step_name() click to toggle source
# File lib/flows/shared_context_pipeline/track_list.rb, line 25
def first_step_name
  @tracks[:main].first_step_name
end
initialize_dup(_other) click to toggle source
# File lib/flows/shared_context_pipeline/track_list.rb, line 12
def initialize_dup(_other)
  @tracks = @tracks.transform_values(&:dup)
end
main_track_empty?() click to toggle source
# File lib/flows/shared_context_pipeline/track_list.rb, line 29
def main_track_empty?
  @tracks[:main].empty?
end
switch_track(track_name) click to toggle source
# File lib/flows/shared_context_pipeline/track_list.rb, line 16
def switch_track(track_name)
  @tracks[track_name] ||= Track.new(track_name)
  @current_track = track_name
end
to_flow(method_source) click to toggle source
# File lib/flows/shared_context_pipeline/track_list.rb, line 41
def to_flow(method_source)
  raise NoStepsError, method_source if main_track_empty?

  Flows::Flow.new(
    start_node: first_step_name,
    node_map: to_node_map(method_source)
  )
end
to_node_map(method_source) click to toggle source
# File lib/flows/shared_context_pipeline/track_list.rb, line 33
def to_node_map(method_source)
  @tracks.reduce({}) do |node_map, (_, track)|
    node_map.merge!(
      track.to_node_map(method_source)
    )
  end
end