From 7d37ce6c4ac6b295916fe98477e601e50e0c51da Mon Sep 17 00:00:00 2001 From: Vladimir Dobriakov Date: Thu, 16 Oct 2025 09:39:23 +0200 Subject: [PATCH] Revert "Update conditional argument handling to correctly support lambdas" This reverts commit 24212f4ad2036d0378b14c830f454261fdf7c977. --- lib/workflow/event.rb | 10 +++------- test/conditionals_test.rb | 3 +-- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/workflow/event.rb b/lib/workflow/event.rb index c425dd7..341c7e5 100644 --- a/lib/workflow/event.rb +++ b/lib/workflow/event.rb @@ -28,13 +28,9 @@ def condition_applicable?(object, event_arguments) object.send(condition, *event_arguments) end else - # Blocks and non-lambda Procs can ignore extra arguments without raising an error in Ruby, - # but lambdas cannot, so we still have to check arity - if condition.arity == 1 # no additional parameters accepted - condition.call(object) - else - condition.call(object, *event_arguments) - end + # since blocks can ignore extra arguments without raising an error in Ruby, + # no `if` is needed - compare with `arity` switch in above methods handling + condition.call(object, *event_arguments) end else true diff --git a/test/conditionals_test.rb b/test/conditionals_test.rb index 6f9fae3..f4352bb 100644 --- a/test/conditionals_test.rb +++ b/test/conditionals_test.rb @@ -92,8 +92,7 @@ def check_low_battery?() # supports no arguments, lets test below, what happens event :turn_on, :transitions_to => :low_battery # otherwise end state :on do - # Use a lambda proc, which enforces correct arity - event :check, :transitions_to => :low_battery, :if => -> (obj) { return false } + event :check, :transitions_to => :low_battery, :if => proc { |obj| return false } event :check, :transitions_to => :on # stay in on state otherwise end state :low_battery