Class: Ad::AgentArchitecture::Dsl::AttributeDsl

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

Overview

This class is responsible for defining the attributes of a workflow

Instance Attribute Summary collapse

Attributes inherited from ChildDsl

#workflow

Instance Method Summary collapse

Methods inherited from ChildDsl

#data, #initialize

Methods included from DataAccessors

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

Constructor Details

This class inherits a constructor from Ad::AgentArchitecture::Dsl::ChildDsl

Instance Attribute Details

#current_attributeObject (readonly)

Returns the value of attribute current_attribute.



8
9
10
# File 'lib/ad/agent_architecture/dsl/attribute_dsl.rb', line 8

def current_attribute
  @current_attribute
end

Instance Method Details

#attribute(name, type: :string, is_array: false, description: nil, &block) ⇒ Object

Raises:

  • (ArgumentError)


10
11
12
13
14
15
16
17
18
19
20
# File 'lib/ad/agent_architecture/dsl/attribute_dsl.rb', line 10

def attribute(name, type: :string, is_array: false, description: nil, &block)
  raise ArgumentError, 'Attribute name must be a string or symbol' unless name.is_a?(String) || name.is_a?(Symbol)

  @current_attribute = { name: name, type: type, is_array: is_array, description: description }

  attributes[name] = current_attribute

  instance_eval(&block) if block_given?

  self
end

#description(description) ⇒ Object



22
23
24
25
26
# File 'lib/ad/agent_architecture/dsl/attribute_dsl.rb', line 22

def description(description)
  current_attribute[:description] = description

  self
end

#is_array(is_array) ⇒ Object



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

def is_array(is_array)
  current_attribute[:is_array] = is_array

  self
end

#type(type) ⇒ Object



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

def type(type)
  current_attribute[:type] = type

  self
end