Class: RailsWorkflow::ProcessManager

Inherits:
Object
  • Object
show all
Defined in:
app/managers/rails_workflow/process_manager.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(process = nil) ⇒ ProcessManager

Returns a new instance of ProcessManager.



18
19
20
21
22
23
# File 'app/managers/rails_workflow/process_manager.rb', line 18

def initialize process = nil
  if process
    @process = process
    @template = process.template
  end
end

Instance Attribute Details

#processObject

Returns the value of attribute process.



16
17
18
# File 'app/managers/rails_workflow/process_manager.rb', line 16

def process
  @process
end

#templateObject

Returns the value of attribute template.



16
17
18
# File 'app/managers/rails_workflow/process_manager.rb', line 16

def template
  @template
end

Class Method Details

.build_process(template_id, context) ⇒ Object



4
5
6
7
# File 'app/managers/rails_workflow/process_manager.rb', line 4

def build_process template_id, context
  template = RailsWorkflow::ProcessTemplate.find template_id
  template.build_process! context
end

.start_process(template_id, context) ⇒ Object



9
10
11
12
13
# File 'app/managers/rails_workflow/process_manager.rb', line 9

def start_process template_id, context
  process = build_process template_id, context
  process.try(:start)
  process
end

Instance Method Details

#complete_processObject



41
42
43
44
45
46
# File 'app/managers/rails_workflow/process_manager.rb', line 41

def complete_process
  if process.can_complete?
    process.complete

  end
end

#operation_complete(operation) ⇒ Object



35
36
37
38
39
# File 'app/managers/rails_workflow/process_manager.rb', line 35

def operation_complete operation
  process.operation_complete operation

  complete_process
end

#operation_exceptionObject



31
32
33
# File 'app/managers/rails_workflow/process_manager.rb', line 31

def operation_exception
  process.operation_exception
end

#start_processObject



25
26
27
28
29
# File 'app/managers/rails_workflow/process_manager.rb', line 25

def start_process
  process.start
rescue => exception
  RailsWorkflow::Error.create_from exception, parent: process
end