Sha256: 7023aedfafa55587a0b167c62b0ea77e26a0380f760731fbad89bd70796a736b

Contents?: true

Size: 627 Bytes

Versions: 18

Compression:

Stored size: 627 Bytes

Contents

module Taskinator
  module Workflow

    def current_state
      @current_state ||= load_workflow_state
    end

    def current_state=(new_state)
      return if new_state == @current_state
      @current_state = persist_workflow_state(new_state)
    end

    def transition(new_state)
      self.current_state = new_state
      yield if block_given?
      current_state
    end

    %i(
      initial
      enqueued
      processing
      paused
      resumed
      completed
      cancelled
      failed
    ).each do |state|

      define_method :"#{state}?" do
        current_state == state
      end

    end

  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
taskinator-0.5.2 lib/taskinator/workflow.rb
taskinator-0.5.1 lib/taskinator/workflow.rb
taskinator-0.5.0 lib/taskinator/workflow.rb
taskinator-0.4.7 lib/taskinator/workflow.rb
taskinator-0.4.6 lib/taskinator/workflow.rb
taskinator-0.4.5 lib/taskinator/workflow.rb
taskinator-0.4.4 lib/taskinator/workflow.rb
taskinator-0.4.3 lib/taskinator/workflow.rb
taskinator-0.4.2 lib/taskinator/workflow.rb
taskinator-0.4.1 lib/taskinator/workflow.rb
taskinator-0.4.0 lib/taskinator/workflow.rb
taskinator-0.3.16 lib/taskinator/workflow.rb
taskinator-0.3.15 lib/taskinator/workflow.rb
taskinator-0.3.14 lib/taskinator/workflow.rb
taskinator-0.3.13 lib/taskinator/workflow.rb
taskinator-0.3.12 lib/taskinator/workflow.rb
taskinator-0.3.11 lib/taskinator/workflow.rb
taskinator-0.3.10 lib/taskinator/workflow.rb