Sha256: 234052dc3d3173487fc2fe8ac9179deec3279b5ae20602ed45c11701ebe8d867

Contents?: true

Size: 848 Bytes

Versions: 20

Compression:

Stored size: 848 Bytes

Contents

module Smash
  module CloudPowers
    class Workflow
      attr_accessor :all_states, :first, :last, :previous, :states

      def initialize(statez = nil)
        # TODO: figure out wtf here with the i-vars changing each other
        @all_states = statez || [:backlog, :wip, :done]
        @states = statez || [:backlog, :wip, :done]
        @first = (statez || [:backlog, :wip, :done]).first
        @last = (statez || [:backlog, :wip, :done]).last
        @previous = [(statez || [:backlog, :wip, :done]).first]
      end

      def current
        @states.first
      end

      def finished?
        @states.first == @states.last
      end

      def next
        finished ? @states.first : @states[1]
      end

      def next!
        return if finished?
        @previous << @states.shift
        @states.first
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
cloud_powers-0.2.7.17 lib/cloud_powers/workflow.rb
cloud_powers-0.2.7.16 lib/cloud_powers/workflow.rb
cloud_powers-0.2.7.15 lib/cloud_powers/workflow.rb
cloud_powers-0.2.7.14 lib/cloud_powers/workflow.rb
cloud_powers-0.2.7.12 lib/cloud_powers/workflow.rb
cloud_powers-0.2.7.11 lib/cloud_powers/workflow.rb
cloud_powers-0.2.7.10 lib/cloud_powers/workflow.rb
cloud_powers-0.2.7.9 lib/cloud_powers/workflow.rb
cloud_powers-0.2.7.8 lib/cloud_powers/workflow.rb
cloud_powers-0.2.7.7 lib/cloud_powers/workflow.rb
cloud_powers-0.2.7.6 lib/cloud_powers/workflow.rb
cloud_powers-0.2.7.5 lib/cloud_powers/workflow.rb
cloud_powers-0.2.7.4 lib/cloud_powers/workflow.rb
cloud_powers-0.2.7.3 lib/cloud_powers/workflow.rb
cloud_powers-0.2.7.2 lib/cloud_powers/workflow.rb
cloud_powers-0.2.7.1 lib/cloud_powers/workflow.rb
cloud_powers-0.2.7 lib/cloud_powers/workflow.rb
cloud_powers-0.2.6 lib/cloud_powers/workflow.rb
cloud_powers-0.2.5 lib/cloud_powers/workflow.rb
cloud_powers-0.2.4 lib/cloud_powers/workflow.rb