Sha256: 0a416c6c3df608314c022471e2c81813753985c7d99c632c1c8530978c1af103

Contents?: true

Size: 1.25 KB

Versions: 2

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

module Ad
  module AgentArchitecture
    module Dsl
      # This class is responsible for defining the workflow DSL
      class WorkflowDsl
        include DataAccessors

        attr_reader :data

        def initialize(name, description: nil)
          @data = { name: name, description: description, sections: [], attributes: {}, prompts: {}, settings: {} }
          @current_section_order = 1
        end

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

        def settings(&block)
          dsl = SettingsDsl.new(self)
          dsl.instance_eval(&block) if block_given?
          dsl
        end

        def attributes(&block)
          dsl = AttributeDsl.new(self)
          dsl.instance_eval(&block) if block_given?
          dsl
        end

        def prompts(&block)
          dsl = PromptDsl.new(self)
          dsl.instance_eval(&block) if block_given?
          dsl
        end

        def section(name, description: nil, &block)
          dsl = SectionDsl.new(self, name, @current_section_order, description: description)
          @current_section_order += 1
          dsl.instance_eval(&block) if block_given?
          dsl
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ad-agent_architecture-0.0.24 lib/ad/agent_architecture/dsl/workflow_dsl.rb
ad-agent_architecture-0.0.23 lib/ad/agent_architecture/dsl/workflow_dsl.rb