Sha256: 6786c48c979ccf8b828ca0ec2c7eaba4030559284aeb2a5707fa7889beea0c8f

Contents?: true

Size: 967 Bytes

Versions: 2

Compression:

Stored size: 967 Bytes

Contents

# frozen_string_literal: true

module Floe
  class Workflow
    class State
      include Logging

      class << self
        def build!(workflow, name, payload)
          state_type = payload["Type"]

          begin
            klass = Floe::Workflow::States.const_get(state_type)
          rescue NameError
            raise Floe::InvalidWorkflowError, "Invalid state type: [#{state_type}]"
          end

          klass.new(workflow, name, payload)
        end
      end

      attr_reader :workflow, :comment, :name, :type, :payload

      def initialize(workflow, name, payload)
        @workflow = workflow
        @name     = name
        @payload  = payload
        @end      = !!payload["End"]
        @type     = payload["Type"]
        @comment  = payload["Comment"]
      end

      def end?
        @end
      end

      def context
        workflow.context
      end

      def status
        end? ? "success" : "running"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
floe-0.2.3 lib/floe/workflow/state.rb
floe-0.2.2 lib/floe/workflow/state.rb