Class: UserNotifier::EmailWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Worker
Defined in:
app/workers/user_notifier/email_worker.rb

Instance Method Summary collapse

Instance Method Details

#perform(model_name, notification_id) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'app/workers/user_notifier/email_worker.rb', line 5

def perform model_name, notification_id
  resource = notification_model(model_name).find_by id: notification_id
  # We don't want to raise exceptions in case our notification does not exist in the database
  if resource
    resource.update_attribute :sent_at, DateTime.now
    resource.deliver_without_worker
  else
    raise "Notification #{notification_id} not found.. sending to retry queue"
  end
end