Class: Ad::AgentArchitecture::Dsl::SectionDsl

Inherits:
ChildDsl
  • Object
show all
Defined in:
lib/ad/agent_architecture/dsl/section_dsl.rb

Overview

This class is responsible for creating a section in the workflow

Instance Attribute Summary

Attributes inherited from ChildDsl

#workflow

Instance Method Summary collapse

Methods inherited from ChildDsl

#data

Methods included from DataAccessors

#attributes, #get_attribute, #get_prompt, #get_setting, #prompt_content, #prompts, #sections, #setting_value, #settings

Constructor Details

#initialize(workflow, name, order, description: nil) ⇒ SectionDsl

Returns a new instance of SectionDsl.



8
9
10
11
12
13
14
# File 'lib/ad/agent_architecture/dsl/section_dsl.rb', line 8

def initialize(workflow, name, order, description: nil)
  super(workflow)

  @section = { name: name, order: order, description: description, steps: [] }
  sections << @section
  @current_step_order = 1
end

Instance Method Details

#description(description) ⇒ Object



16
17
18
19
20
# File 'lib/ad/agent_architecture/dsl/section_dsl.rb', line 16

def description(description)
  @section[:description] = description

  self
end

#step(name, description: nil, &block) ⇒ Object

Raises:

  • (ArgumentError)


22
23
24
25
26
27
28
29
# File 'lib/ad/agent_architecture/dsl/section_dsl.rb', line 22

def step(name, description: nil, &block)
  raise ArgumentError, 'Step name must be a string or symbol' unless name.is_a?(String) || name.is_a?(Symbol)

  StepDsl.new(workflow, @section, name, @current_step_order, description: description).instance_eval(&block)
  @current_step_order += 1

  self
end