Sha256: 0685ffc0c12a5b3ff7b100eb1472aae163eb9522272f14d8e43da8d42de7b70f
Contents?: true
Size: 1.2 KB
Versions: 13
Compression:
Stored size: 1.2 KB
Contents
# frozen_string_literal: true module Floe class Workflow class ChoiceRule class << self def build(payload) if (sub_payloads = payload["Not"]) Floe::Workflow::ChoiceRule::Not.new(payload, build_children([sub_payloads])) elsif (sub_payloads = payload["And"]) Floe::Workflow::ChoiceRule::And.new(payload, build_children(sub_payloads)) elsif (sub_payloads = payload["Or"]) Floe::Workflow::ChoiceRule::Or.new(payload, build_children(sub_payloads)) else Floe::Workflow::ChoiceRule::Data.new(payload) end end def build_children(sub_payloads) sub_payloads.map { |payload| build(payload) } end end attr_reader :next, :payload, :variable, :children def initialize(payload, children = nil) @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
13 entries across 13 versions & 1 rubygems