Module: RailsWorkflow::ProcessTemplates::DefaultBuilder
- Extended by:
- ActiveSupport::Concern
- Included in:
- RailsWorkflow::ProcessTemplate
- Defined in:
- app/concerns/rails_workflow/process_templates/default_builder.rb
Overview
DefaultBuilder is responsible for building new process and it's initial (independent) operations.
Instance Method Summary (collapse)
-
- (Object) build_independent_operations(process)
Independent operations is template operations that have no dependencies on any other operations.
-
- (Object) build_operation(process, template, completed_dependencies = [])
Building new operation for given process.
-
- (Object) build_process!(context)
When process manager building new process, it initializes process template for new process and call this method to build new process instance.
Instance Method Details
- (Object) build_independent_operations(process)
Independent operations is template operations that have no dependencies on any other operations.
33 34 35 36 37 |
# File 'app/concerns/rails_workflow/process_templates/default_builder.rb', line 33 def build_independent_operations process independent_operations.each do |operation_template| build_operation process, operation_template end end |
- (Object) build_operation(process, template, completed_dependencies = [])
Building new operation for given process.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/concerns/rails_workflow/process_templates/default_builder.rb', line 43 def build_operation process, template, completed_dependencies = [] operation = template.build_operation! process, completed_dependencies if operation.present? process.operations << operation end operation rescue => exception RailsWorkflow::Error.create_from( exception, { parent: process, target: process.template, method: :build_operation, args: [process, template, completed_dependencies] } ) end |
- (Object) build_process!(context)
When process manager building new process, it initializes process template for new process and call this method to build new process instance. This method buildling new process and initial operations (operations that has no dependencies on any other operations and can be build before process starts).
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/concerns/rails_workflow/process_templates/default_builder.rb', line 16 def build_process! context process = process_class.create template: self process.class.transaction do process.update_attributes({title: self.title, status: Process::NOT_STARTED}) process.create_context(data: context, parent: process) build_independent_operations process process.reload build_process(process) if respond_to? :build_process process end end |