Module: LcpRuby::Workflow::Setup

Defined in:
lib/lcp_ruby/workflow/setup.rb

Class Method Summary collapse

Class Method Details

.apply!(loader) ⇒ Object

Boot-time setup for the workflow subsystem. Called after models are built and groups/auditing are set up.

Parameters:



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/lcp_ruby/workflow/setup.rb', line 8

def self.apply!(loader)
  sources = []

  # Static source always loads if workflow files exist
  if loader.workflow_definitions.any?
    sources << StaticSource.new(loader.workflow_definitions)
  end

  # Additional source based on configuration
  config_source = LcpRuby.configuration.workflow_source
  case config_source
  when :model
    model_src = setup_model!(loader)
    sources << model_src if model_src
  when :host
    host_src = setup_host!
    sources << host_src if host_src
  end

  return if sources.empty?

  resolver = Resolver.new(sources)
  Registry.set_loader(resolver)
  Registry.mark_available!

  # Set up audit log if any workflow has audit_log: true
  setup_audit_log!(loader)

  # Set up approval engine if any workflow has approvals
  Approval::Setup.apply!(loader)
end