Class: FlowEngine::DSL::StepBuilder
- Inherits:
-
Object
- Object
- FlowEngine::DSL::StepBuilder
- Includes:
- RuleHelpers
- Defined in:
- lib/flowengine/dsl/step_builder.rb
Overview
Builds a single Node from step DSL (type, question, options, transitions, visibility). Used by FlowBuilder#step; includes RuleHelpers for transition/visibility conditions.
Instance Method Summary collapse
-
#build(id) ⇒ Node
Builds the Node for the given step id from accumulated attributes.
-
#decorations(decorations) ⇒ Object
Optional UI decorations (opaque to the engine).
-
#fields(list) ⇒ Object
Sets the list of field names for matrix-style steps (e.g. number_matrix).
-
#initialize ⇒ StepBuilder
constructor
A new instance of StepBuilder.
-
#max_clarifications(count) ⇒ Object
Sets the maximum number of clarification rounds for an :ai_intake step.
-
#options(list) ⇒ Object
Sets the list of options for multi-select or choice steps.
-
#question(text) ⇒ Object
Sets the prompt/label for the step.
-
#transition(to:, if_rule: nil) ⇒ Object
Adds a conditional transition to another step.
-
#type(value) ⇒ Object
Sets the step/input type (e.g. :multi_select, :number_matrix).
-
#visible_if(rule) ⇒ Object
Sets the visibility rule for this step (DAG mode: step shown only when rule is true).
Methods included from RuleHelpers
#all, #any, #contains, #equals, #greater_than, #less_than, #not_empty
Constructor Details
#initialize ⇒ StepBuilder
Returns a new instance of StepBuilder.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/flowengine/dsl/step_builder.rb', line 10 def initialize @type = nil @question = nil @options = nil @fields = nil @transitions = [] @visibility_rule = nil @decorations = nil @max_clarifications = 0 end |
Instance Method Details
#build(id) ⇒ Node
Builds the Node for the given step id from accumulated attributes.
77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/flowengine/dsl/step_builder.rb', line 77 def build(id) Node.new( id: id, type: @type, question: @question, options: @options, fields: @fields, transitions: @transitions, visibility_rule: @visibility_rule, decorations: @decorations, max_clarifications: @max_clarifications ) end |
#decorations(decorations) ⇒ Object
Optional UI decorations (opaque to the engine).
47 48 49 |
# File 'lib/flowengine/dsl/step_builder.rb', line 47 def decorations(decorations) @decorations = decorations end |
#fields(list) ⇒ Object
Sets the list of field names for matrix-style steps (e.g. number_matrix).
41 42 43 |
# File 'lib/flowengine/dsl/step_builder.rb', line 41 def fields(list) @fields = list end |
#max_clarifications(count) ⇒ Object
Sets the maximum number of clarification rounds for an :ai_intake step.
69 70 71 |
# File 'lib/flowengine/dsl/step_builder.rb', line 69 def max_clarifications(count) @max_clarifications = count end |
#options(list) ⇒ Object
Sets the list of options for multi-select or choice steps.
35 36 37 |
# File 'lib/flowengine/dsl/step_builder.rb', line 35 def (list) @options = list end |
#question(text) ⇒ Object
Sets the prompt/label for the step.
29 30 31 |
# File 'lib/flowengine/dsl/step_builder.rb', line 29 def question(text) @question = text end |
#transition(to:, if_rule: nil) ⇒ Object
Adds a conditional transition to another step. First matching transition wins.
55 56 57 |
# File 'lib/flowengine/dsl/step_builder.rb', line 55 def transition(to:, if_rule: nil) @transitions << Transition.new(target: to, rule: if_rule) end |
#type(value) ⇒ Object
Sets the step/input type (e.g. :multi_select, :number_matrix).
23 24 25 |
# File 'lib/flowengine/dsl/step_builder.rb', line 23 def type(value) @type = value end |
#visible_if(rule) ⇒ Object
Sets the visibility rule for this step (DAG mode: step shown only when rule is true).
62 63 64 |
# File 'lib/flowengine/dsl/step_builder.rb', line 62 def visible_if(rule) @visibility_rule = rule end |