Class: Ad::AgentArchitecture::Dsl::StepDsl

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

Overview

This class is responsible for defining the steps of a section

Instance Attribute Summary collapse

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, section, name, order, description: nil) ⇒ StepDsl

Returns a new instance of StepDsl.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ad/agent_architecture/dsl/step_dsl.rb', line 13

def initialize(workflow, section, name, order, description: nil)
  super(workflow)
  @step = {
    name: name,
    order: order,
    description: description,
    prompt: '',
    input_attributes: [],
    output_attributes: []
  }

  @section = section
  @section[:steps] << @step
end

Instance Attribute Details

#sectionObject (readonly)

Returns the value of attribute section.



10
11
12
# File 'lib/ad/agent_architecture/dsl/step_dsl.rb', line 10

def section
  @section
end

#stepObject (readonly)

Returns the value of attribute step.



11
12
13
# File 'lib/ad/agent_architecture/dsl/step_dsl.rb', line 11

def step
  @step
end

Instance Method Details

#description(description) ⇒ Object



46
47
48
49
# File 'lib/ad/agent_architecture/dsl/step_dsl.rb', line 46

def description(description)
  @step[:description] = description
  self
end

#input(name, **_opts) ⇒ Object



28
29
30
31
32
# File 'lib/ad/agent_architecture/dsl/step_dsl.rb', line 28

def input(name, **_opts)
  infer_attribute(name)
  @step[:input_attributes] << name
  self
end

#output(name, **_opts) ⇒ Object



34
35
36
37
38
# File 'lib/ad/agent_architecture/dsl/step_dsl.rb', line 34

def output(name, **_opts)
  infer_attribute(name)
  @step[:output_attributes] << name
  self
end

#prompt(prompt, **_opts) ⇒ Object



40
41
42
43
44
# File 'lib/ad/agent_architecture/dsl/step_dsl.rb', line 40

def prompt(prompt, **_opts)
  content = prompt_content(prompt)
  @step[:prompt] = content || prompt
  self
end