class RailsWorkflow::DependencyResolver
New operation can be added to process if all it's dependencies are satisfied. For example current operation can depend on some existing process operation which should be completed - then current operation can be build
Attributes
process[RW]
Public Class Methods
new(process)
click to toggle source
# File lib/rails_workflow/dependency_resolver.rb, line 15 def initialize(process) @process = process end
Public Instance Methods
build_new_operations(operation)
click to toggle source
# File lib/rails_workflow/dependency_resolver.rb, line 19 def build_new_operations(operation) [].tap do |new_operations| matched_templates(operation).each do |operation_template| completed_dependencies = [operation] new_operations << operation_builder.new( process, operation_template, completed_dependencies ).create_operation end end.compact rescue => exception handle_exception(exception, operation) end
Private Instance Methods
already_built_templates()
click to toggle source
# File lib/rails_workflow/dependency_resolver.rb, line 70 def already_built_templates operations.map(&:template) end
config()
click to toggle source
# File lib/rails_workflow/dependency_resolver.rb, line 47 def config RailsWorkflow.config end
dependent_templates(operation)
click to toggle source
# File lib/rails_workflow/dependency_resolver.rb, line 66 def dependent_templates(operation) template.dependent_operations(operation) end
error_builder()
click to toggle source
# File lib/rails_workflow/dependency_resolver.rb, line 43 def error_builder config.error_builder end
handle_exception(exception, operation)
click to toggle source
# File lib/rails_workflow/dependency_resolver.rb, line 35 def handle_exception(exception, operation) error_builder.handle( exception, parent: process, target: :dependency_resolver, method: :build_new_operations, args: [operation] ) end
matched_templates(operation)
click to toggle source
# File lib/rails_workflow/dependency_resolver.rb, line 59 def matched_templates(operation) (dependent_templates(operation) - already_built_templates) .select do |operation_template| operation_template.resolve_dependency operation end end
operation_builder()
click to toggle source
# File lib/rails_workflow/dependency_resolver.rb, line 55 def operation_builder config.operation_builder end
operation_runner()
click to toggle source
# File lib/rails_workflow/dependency_resolver.rb, line 51 def operation_runner config.operation_runner end