Skip to content

Instantly share code, notes, and snippets.

@m-nakamura145
Created November 27, 2018 03:24
Show Gist options
  • Save m-nakamura145/64a59cc9398e088b81592881e4f513ba to your computer and use it in GitHub Desktop.
Save m-nakamura145/64a59cc9398e088b81592881e4f513ba to your computer and use it in GitHub Desktop.
require 'worker/base_worker'
class NotifyCancelledReservationWorker < BaseWorker
sidekiq_options queue: :reservation, retry: 3
def perform(reservation_id)
reservation = Reservation.find(reservation_id)
reservation.notify_cancelled
end
end
# Bad Design
#
# class NotifyReservationStatusWorker < BaseWorker
# sidekiq_options queue: :reservation, retry: 3
#
# def perform(reservation_id, status)
# reservation = Reservation.find(reservation_id)
#
# case status
# when 'cancelled'
# reservation.notify_cancelled
# when 'visited'
# reservation.notify_visited
# end
# end
# end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment