Sha256: 292be08a1967030e7675e5258a398cfe9d425654ae1db5d4a5f55a3e19cab508
Contents?: true
Size: 830 Bytes
Versions: 2
Compression:
Stored size: 830 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!(input) input = input_path.value(context, input) next_state = choices.detect { |choice| choice.true?(context, input) }&.next || default output = output_path.value(context, input) [next_state, output] end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
floe-0.2.3 | lib/floe/workflow/states/choice.rb |
floe-0.2.2 | lib/floe/workflow/states/choice.rb |