class RailsWorkflow::ProcessBuilder

DefaultBuilder

Process Builder is used to build new process. All process building logic should be gathered here. It defines how process is build using template (for example it can used to gather some additional information from system - for example some information from existing processes or it can handle hierarchical processes logic for parent / child processes).

Attributes

context[RW]
template[RW]

Public Class Methods

new(template, context) click to toggle source
# File lib/rails_workflow/process_builder.rb, line 16
def initialize(template, context)
  @template = template
  @context = context
end

Public Instance Methods

build_independent_operations(process) click to toggle source

Independent operations is template operations that have no dependencies from any other operations

# File lib/rails_workflow/process_builder.rb, line 33
def build_independent_operations(process)
  independent_operations.each do |operation_template|
    build_operation process, operation_template
  end
end
build_operation(process, template, completed_dependencies = []) click to toggle source
# File lib/rails_workflow/process_builder.rb, line 39
def build_operation(process, template, completed_dependencies = [])
  operation_builder.new(
    process, template, completed_dependencies
  ).create_operation
end
config() click to toggle source
# File lib/rails_workflow/process_builder.rb, line 49
def config
  RailsWorkflow.config
end
create_process!() click to toggle source
# File lib/rails_workflow/process_builder.rb, line 21
def create_process!
  process = process_class.create(template: template)

  process.update_attributes(title: title, status: Process::NOT_STARTED)
  process.create_context(data: context, parent: process)

  build_independent_operations process
  process
end
error_builder() click to toggle source
# File lib/rails_workflow/process_builder.rb, line 45
def error_builder
  config.error_builder
end
operation_builder() click to toggle source
# File lib/rails_workflow/process_builder.rb, line 53
def operation_builder
  config.operation_builder
end