Class: SpreeUberDirect::OrderCompletedSubscriber

Inherits:
Spree::Subscriber
  • Object
show all
Defined in:
app/subscribers/spree_uber_direct/order_completed_subscriber.rb

Overview

Events & Subscribers is the preferred pattern for this kind of side effect (per this app's own CLAUDE.md conventions) — react to order.completed without touching Spree::Order itself. Mirrors SpreeDoordash::OrderCompletedSubscriber's shape exactly; independent of it and of spree_square's own subscriber on the same event — Spree's Events system already fires all three separately for every order (confirmed live earlier in this project: each shows up as its own Spree::Events::SubscriberJob entry for the same event).

Instance Method Summary collapse

Instance Method Details

#handle(event) ⇒ Object



13
14
15
16
17
18
19
# File 'app/subscribers/spree_uber_direct/order_completed_subscriber.rb', line 13

def handle(event)
  order = Spree::Order.find_by_prefix_id(event.payload['id'])
  return unless order
  return unless uber_direct_delivery?(order)

  SpreeUberDirect::DeliveryDispatchJob.perform_later(order.id)
end