Sha256: bb53f8c30c92afc118e3400ee116352b10b9393f5b5569225503b7f6e06d034a
Contents?: true
Size: 862 Bytes
Versions: 2
Compression:
Stored size: 862 Bytes
Contents
# frozen_string_literal: true module Floe class Workflow module States class Choice < Floe::Workflow::State attr_reader :choices, :default, :input_path, :output_path def initialize(workflow, name, payload) super @choices = payload["Choices"].map { |choice| ChoiceRule.build(choice) } @default = payload["Default"] @input_path = Path.new(payload.fetch("InputPath", "$")) @output_path = Path.new(payload.fetch("OutputPath", "$")) end def run!(*) super do |input| next_state_name = choices.detect { |choice| choice.true?(context, input) }&.next || default next_state = workflow.states_by_name[next_state_name] output = input [output, next_state] end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
floe-0.2.1 | lib/floe/workflow/states/choice.rb |
floe-0.2.0 | lib/floe/workflow/states/choice.rb |