Skip to content

Commit

Permalink
preprocess Data path
Browse files Browse the repository at this point in the history
get payload out of the runtime and into the initialization
  • Loading branch information
kbrock committed May 23, 2024
1 parent 1488c5c commit c95f621
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/floe/workflow/choice_rule/data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c95f621

Please sign in to comment.