Sha256: fbfc8d9323a433418e19cf4986675390ca66c393daf0b3b0d8d0a4c6b30c7331
Contents?: true
Size: 1.54 KB
Versions: 2
Compression:
Stored size: 1.54 KB
Contents
# frozen_string_literal: true module Floe class Workflow class ChoiceRule class << self def build(workflow, name, payload) if (sub_payloads = payload["Not"]) name += ["Not"] Floe::Workflow::ChoiceRule::Not.new(workflow, name, payload, build_children(workflow, name, [sub_payloads])) elsif (sub_payloads = payload["And"]) name += ["And"] Floe::Workflow::ChoiceRule::And.new(workflow, name, payload, build_children(workflow, name, sub_payloads)) elsif (sub_payloads = payload["Or"]) name += ["Or"] Floe::Workflow::ChoiceRule::Or.new(workflow, name, payload, build_children(workflow, name, sub_payloads)) else name += ["Data"] Floe::Workflow::ChoiceRule::Data.new(workflow, name, payload) end end def build_children(workflow, name, sub_payloads) sub_payloads.map.with_index { |payload, i| build(workflow, name + [i.to_s], payload) } end end attr_reader :next, :payload, :variable, :children, :name def initialize(_workflow, name, payload, children = nil) @name = name @payload = payload @children = children @next = payload["Next"] @variable = payload["Variable"] end def true?(*) raise NotImplementedError, "Must be implemented in a subclass" end private def variable_value(context, input) Path.value(variable, context, input) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
floe-0.13.0 | lib/floe/workflow/choice_rule.rb |
floe-0.12.0 | lib/floe/workflow/choice_rule.rb |