Class: Workarea::RestockNotifier
- Inherits:
-
Object
- Object
- Workarea::RestockNotifier
- Includes:
- Sidekiq::CallbacksWorker, Sidekiq::Worker
- Defined in:
- app/workers/workarea/restock_notifier.rb
Instance Method Summary collapse
Instance Method Details
#perform(id) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'app/workers/workarea/restock_notifier.rb', line 12 def perform(id) sku = Inventory::Sku.find(id) return unless sku.purchasable? InventoryNotification.unsent.where(sku: sku.id).each do |notification| send_notification(notification); end end |
#send_notification(notification) ⇒ Object
22 23 24 25 |
# File 'app/workers/workarea/restock_notifier.rb', line 22 def send_notification(notification) attrs = notification.attributes.values_at('product_id', 'sku', 'email') notification.mark_as_sent! if Storefront::InventoryUpdateMailer.notify(*attrs).deliver end |