class FlowEngine::Definition

@attr_reader steps [Hash<Symbol, Node>] frozen map of step id => node (read-only)
@attr_reader start_step_id [Symbol] id of the first step in the flow
Built by {DSL::FlowBuilder}; consumed by {Engine} for navigation.
Immutable, versionable flow graph: maps step ids to {Node} objects and defines the entry point.

def initialize(start_step_id:, nodes:, introduction: nil)

Raises:
  • (DefinitionError) - if start_step_id is not present in nodes

Parameters:
  • introduction (Introduction, nil) -- optional introduction config (label + placeholder)
  • nodes (Hash) -- all steps keyed by id
  • start_step_id (Symbol) -- id of the initial step
def initialize(start_step_id:, nodes:, introduction: nil)
  @start_step_id = start_step_id
  @steps = nodes.freeze
  @introduction = introduction
  validate!
  freeze
end

def start_step

Returns:
  • (Node) - the node for the start step
def start_step
  step(start_step_id)
end

def step(id)

Raises:
  • (UnknownStepError) - if id is not in steps

Returns:
  • (Node) - the node for that step

Parameters:
  • id (Symbol) -- step id
def step(id)
  steps.fetch(id) { raise Errors::UnknownStepError, "Unknown step: #{id.inspect}" }
end

def step_ids

Returns:
  • (Array) - all step ids in the definition
def step_ids
  steps.keys
end

def validate!

def validate!
  return if steps.key?(start_step_id)
  raise Errors::DefinitionError, "Start step #{start_step_id.inspect} not found in nodes"
end