Sha256: d5ed3b3ce178ae11458b647e63aa7bf5d7fff84557285c0020a0512ba33debb7

Contents?: true

Size: 1.14 KB

Versions: 3

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

module Floe
  class Workflow
    module States
      class Pass < Floe::Workflow::State
        attr_reader :end, :next, :result, :parameters, :input_path, :output_path, :result_path

        def initialize(workflow, name, payload)
          super

          @next        = payload["Next"]
          @end         = !!payload["End"]
          @result      = payload["Result"]

          @parameters  = PayloadTemplate.new(payload["Parameters"]) if payload["Parameters"]
          @input_path  = Path.new(payload.fetch("InputPath", "$"))
          @output_path = Path.new(payload.fetch("OutputPath", "$"))
          @result_path = ReferencePath.new(payload.fetch("ResultPath", "$"))
        end

        def start(input)
          super
          output = input_path.value(context, input)
          output = result_path.set(output, result) if result && result_path
          output = output_path.value(context, output)

          context.next_state = end? ? nil : @next
          context.output     = output
        end

        def running?
          false
        end

        def end?
          @end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
floe-0.5.0 lib/floe/workflow/states/pass.rb
floe-0.4.1 lib/floe/workflow/states/pass.rb
floe-0.4.0 lib/floe/workflow/states/pass.rb