Sha256: 26b7f4988c57c495fb36a95fe770c7b2150535352f59b7e5e6960bfef870028e

Contents?: true

Size: 826 Bytes

Versions: 2

Compression:

Stored size: 826 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
        @type     = payload["Type"]
        @comment  = payload["Comment"]
      end

      def context
        workflow.context
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
floe-0.3.1 lib/floe/workflow/state.rb
floe-0.3.0 lib/floe/workflow/state.rb