From c95f621d3f15061b8fee6be99c8cffc9112b672e Mon Sep 17 00:00:00 2001 From: Keenan Brock Date: Wed, 22 May 2024 22:12:37 -0400 Subject: [PATCH] preprocess Data path get payload out of the runtime and into the initialization --- lib/floe/workflow/choice_rule/data.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/floe/workflow/choice_rule/data.rb b/lib/floe/workflow/choice_rule/data.rb index 699a9eed..9ae8749d 100644 --- a/lib/floe/workflow/choice_rule/data.rb +++ b/lib/floe/workflow/choice_rule/data.rb @@ -11,8 +11,13 @@ class Data < Floe::Workflow::ChoiceRule def initialize(*) super @compare_key = payload.keys.detect { |key| key.match?(/^(#{COMPARE_KEYS.join("|")})/) } - raise Floe::InvalidWorkflowError, "Data-test Expression Choice Rule must have a compare key" if @compare_key.nil? + + if @compare_key&.end_with?("Path") + @ref_path = payload[compare_key] + else + @ref = payload[compare_key] + end end def true?(context, input) @@ -91,7 +96,7 @@ def is_timestamp?(value) # rubocop:disable Naming/PredicateName end def compare_value(context, input) - compare_key.end_with?("Path") ? Path.value(payload[compare_key], context, input) : payload[compare_key] + @ref_path ? Path.value(@ref_path, context, input) : @ref end end end