Sha256: 664ecc5efa60b2fec30ef7469ac34fcbca5bde13b471122dc8cb863a3291c112

Contents?: true

Size: 1.48 KB

Versions: 1

Compression:

Stored size: 1.48 KB

Contents

require 'active_support/concern'

module RailsWorkflow
  module OperationStatus
    extend ActiveSupport::Concern

    included do
      NOT_STARTED = 0
      IN_PROGRESS = 1
      DONE = 2

      WAITING = 3
      ERROR = 4

      #operation was in progress and canceled
      CANCELED = 5

      #operation was build but not started and not need to start
      SKIPPED = 6

      #current operation was in progress or complete
      #when process restart or rollback to some previous operation happened
      #this operation is moved to rollback so that rollback operation
      #can be added to template.
      #rollback operation can be used to cancel all changes
      #done by current operation before restart happened
      ROLLBACK = 7

      def incomplete_statuses
        [NOT_STARTED, IN_PROGRESS,]
      end

      def completed_statuses
        [DONE, CANCELED, SKIPPED]
      end

      #in which user can pickup operation and complete it etc.
      def self.user_ready_statuses
        [WAITING]
      end

      def self.ready_to_assign
        [WAITING]
      end

      def self.all_statuses
        (NOT_STARTED..ROLLBACK).to_a
      end

      def get_status_values
        [
            [NOT_STARTED, 'Not Started'],
            [IN_PROGRESS, 'In Progress'],
            [DONE, 'Done'],
            [WAITING, 'Waiting'],
            [ERROR, 'Error'],
            [CANCELED, 'Canceled'],
            [SKIPPED, 'Skipped'],
            [ROLLBACK, 'Rollback']
        ]
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_workflow-0.2.1 app/concerns/rails_workflow/operation_status.rb