Class: MyPusher::ReservationDriver
- Inherits:
-
Object
- Object
- MyPusher::ReservationDriver
- Defined in:
- app/my_lib/my_pusher/reservation_driver.rb
Overview
typed: ignore
Class Method Summary collapse
-
.broadcast_reservation(reservation, action) ⇒ Object
Broadcasts a reservation update to the Pusher channel.
Instance Method Summary collapse
- #notify_alert(reservation) ⇒ Object
- #notify_cancel(reservation) ⇒ Object
- #notify_create(reservation) ⇒ Object
- #notify_update(reservation) ⇒ Object
Class Method Details
.broadcast_reservation(reservation, action) ⇒ Object
Broadcasts a reservation update to the Pusher channel. We use this method to notify the admin dashboard about reservation for delivery updates
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/my_lib/my_pusher/reservation_driver.rb', line 29 def self.broadcast_reservation(reservation, action) return if !reservation.delivery? && reservation.reached_goal? && reservation.pending_payment_non_cc? pusher = ::MyPusher::ReservationDriver.new case action.to_sym when :create pusher.notify_create(reservation) when :update pusher.notify_update(reservation) when :destroy pusher.notify_cancel(reservation) when :alert pusher.notify_alert(reservation) else APMErrorHandler.report('NotImplementedError', reservation_id: reservation.id, action: action) raise NotImplementedError end rescue Pusher::Error => e HH_LOGGER.error e unless e..include? 'quota exceeded' rescue StandardError => e HH_LOGGER.error e end |
Instance Method Details
#notify_alert(reservation) ⇒ Object
14 15 16 |
# File 'app/my_lib/my_pusher/reservation_driver.rb', line 14 def notify_alert(reservation) trigger('alert', { html: reservation_to_html(reservation), id: reservation.id }) end |
#notify_cancel(reservation) ⇒ Object
19 20 21 |
# File 'app/my_lib/my_pusher/reservation_driver.rb', line 19 def notify_cancel(reservation) trigger('alert', { html: reservation_to_html(reservation), id: reservation.id }) end |
#notify_create(reservation) ⇒ Object
9 10 11 |
# File 'app/my_lib/my_pusher/reservation_driver.rb', line 9 def notify_create(reservation) trigger('created', { html: reservation_to_html(reservation), id: reservation.id }) end |
#notify_update(reservation) ⇒ Object
4 5 6 |
# File 'app/my_lib/my_pusher/reservation_driver.rb', line 4 def notify_update(reservation) trigger('updated', { html: reservation_to_html(reservation), id: reservation.id }) end |