Sha256: f0b0df39c10cce495660b75f91cdd6e1bc1cf161251d75713f964e8d73bbfbe8

Contents?: true

Size: 871 Bytes

Versions: 2

Compression:

Stored size: 871 Bytes

Contents

# frozen_string_literal: true

module Floe
  class Workflow
    module States
      class Wait < Floe::Workflow::State
        attr_reader :end, :next, :seconds, :input_path, :output_path

        def initialize(workflow, name, payload)
          super

          @next    = payload["Next"]
          @end     = !!payload["End"]
          @seconds = payload["Seconds"].to_i

          @input_path  = Path.new(payload.fetch("InputPath", "$"))
          @output_path = Path.new(payload.fetch("OutputPath", "$"))
        end

        def run!(input)
          input = input_path.value(context, input)
          sleep(seconds)
          output = output_path.value(context, input)
          [@end ? nil : @next, output]
        end

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

        def end?
          @end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
floe-0.3.1 lib/floe/workflow/states/wait.rb
floe-0.3.0 lib/floe/workflow/states/wait.rb