Sha256: ea9aba3e5c90c50387a1f85282e9e8cde860b121d247e286f25e029b28e901dc

Contents?: true

Size: 993 Bytes

Versions: 10

Compression:

Stored size: 993 Bytes

Contents

module RailsWorkflow
  class ProcessManager
    class << self
      def build_process template_id, context
        template = RailsWorkflow::ProcessTemplate.find template_id
        template.build_process! context
      end

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

    attr_accessor :process, :template

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

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

    def operation_exception
      process.operation_exception
    end

    def operation_complete operation
      process.operation_complete operation

      complete_process
    end

    def complete_process
      if process.can_complete?
        process.complete

      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rails_workflow-0.3.7 app/managers/rails_workflow/process_manager.rb
rails_workflow-0.3.6 app/managers/rails_workflow/process_manager.rb
rails_workflow-0.3.5 app/managers/rails_workflow/process_manager.rb
rails_workflow-0.3.4 app/managers/rails_workflow/process_manager.rb
rails_workflow-0.3.3 app/managers/rails_workflow/process_manager.rb
rails_workflow-0.3.2 app/managers/rails_workflow/process_manager.rb
rails_workflow-0.3.1 app/managers/rails_workflow/process_manager.rb
rails_workflow-0.3.0 app/managers/rails_workflow/process_manager.rb
rails_workflow-0.2.2 app/managers/rails_workflow/process_manager.rb
rails_workflow-0.2.1 app/managers/rails_workflow/process_manager.rb