From 8cd551ea2774f593ebf3aee23ab0dd8132d3665b Mon Sep 17 00:00:00 2001 From: Andrzej Krzywda Date: Tue, 1 Oct 2024 20:32:57 +0200 Subject: [PATCH] More IDE-friendly way of switch-case events by type --- ecommerce/processes/lib/processes/reservation_process.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ecommerce/processes/lib/processes/reservation_process.rb b/ecommerce/processes/lib/processes/reservation_process.rb index 946ed967..e13532c6 100644 --- a/ecommerce/processes/lib/processes/reservation_process.rb +++ b/ecommerce/processes/lib/processes/reservation_process.rb @@ -10,12 +10,12 @@ def initialize def call(event) state = build_state(event) - case event.event_type - when 'Ordering::OrderSubmitted' + case event + when Ordering::OrderSubmitted update_order_state(state) { reserve_stock(state) } - when 'Fulfillment::OrderCancelled' + when Fulfillment::OrderCancelled release_stock(state) - when 'Fulfillment::OrderConfirmed' + when Fulfillment::OrderConfirmed dispatch_stock(state) end end