Class: MyMsgBus::ReservationDriver
- Inherits:
-
Object
- Object
- MyMsgBus::ReservationDriver
- Defined in:
- app/my_lib/my_msg_bus/reservation_driver.rb
Class Method Summary collapse
Instance Method Summary collapse
- #notify_owner(reservation) ⇒ Object
- #remove_notif_owner(reservation) ⇒ Object
- #reservation_to_html(reservation, html_path = 'dashboard/v2/reservations/delivery_info') ⇒ Object
- #valid_status?(status) ⇒ Boolean
Class Method Details
.broadcast_info(reservation) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/my_lib/my_msg_bus/reservation_driver.rb', line 23 def self.broadcast_info(reservation) # msg_bus = MyMsgBus::ReservationDriver.new # driver = reservation&.driver # status = driver&.status # if driver.present? && status.present? && msg_bus.valid_status?(status) # msg_bus.notify_owner(reservation) # else # msg_bus.remove_notif_owner(reservation) # end end |
Instance Method Details
#notify_owner(reservation) ⇒ Object
7 8 9 10 11 12 13 |
# File 'app/my_lib/my_msg_bus/reservation_driver.rb', line 7 def notify_owner(reservation) data = { id: reservation.id, view: reservation_to_html(reservation) } # MessageBus.publish '/reservation-delivery-info', data end |
#remove_notif_owner(reservation) ⇒ Object
15 16 17 18 19 20 21 |
# File 'app/my_lib/my_msg_bus/reservation_driver.rb', line 15 def remove_notif_owner(reservation) data = { id: reservation.id, view: '' } # MessageBus.publish '/reservation-delivery-info', data end |
#reservation_to_html(reservation, html_path = 'dashboard/v2/reservations/delivery_info') ⇒ Object
35 36 37 |
# File 'app/my_lib/my_msg_bus/reservation_driver.rb', line 35 def reservation_to_html(reservation, html_path = 'dashboard/v2/reservations/delivery_info') Dashboard::V2::ReservationsController.render partial: html_path, locals: { reservation: reservation } end |
#valid_status?(status) ⇒ Boolean
39 40 41 42 43 44 |
# File 'app/my_lib/my_msg_bus/reservation_driver.rb', line 39 def valid_status?(status) progress_status = Class.new.extend(ProgressStatus).convert_from_reservation(status) return false if [Driver::DELIVERED, Driver::FINDING_DRIVER].include?(progress_status) true end |