Sha256: 33e4b301e7f0aff12173e409e135b208202622145d43b4273e5e46d758b9b50d

Contents?: true

Size: 881 Bytes

Versions: 6

Compression:

Stored size: 881 Bytes

Contents

# frozen_string_literal: true

module Floe
  class Workflow
    class Catcher
      include ErrorMatcherMixin
      include ValidationMixin

      attr_reader :error_equals, :next, :result_path, :name

      def initialize(workflow, name, payload)
        @name         = name
        @payload      = payload

        @error_equals = payload["ErrorEquals"]
        @next         = payload["Next"]
        @result_path  = ReferencePath.new(payload.fetch("ResultPath", "$"))

        missing_field_error!("ErrorEquals") if !@error_equals.kind_of?(Array) || @error_equals.empty?
        validate_state_next!(workflow)
      end

      private

      def validate_state_next!(workflow)
        missing_field_error!("Next") if @next.nil?
        invalid_field_error!("Next", @next, "is not found in \"States\"") if @next && !workflow_state?(@next, workflow)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
floe-0.15.1 lib/floe/workflow/catcher.rb
floe-0.15.0 lib/floe/workflow/catcher.rb
floe-0.14.0 lib/floe/workflow/catcher.rb
floe-0.13.1 lib/floe/workflow/catcher.rb
floe-0.13.0 lib/floe/workflow/catcher.rb
floe-0.12.0 lib/floe/workflow/catcher.rb