Class: Nuntius::MessengerJob

Inherits:
ApplicationJob show all
Defined in:
app/jobs/nuntius/messenger_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(obj, event, params = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'app/jobs/nuntius/messenger_job.rb', line 6

def perform(obj, event, params = {})
  return unless obj

  messenger = Nuntius::BaseMessenger.messenger_for_obj(obj).new(obj, event, params)
  return unless messenger.is_a?(Nuntius::CustomMessenger) || messenger.respond_to?(event.to_sym)

  messenger.call
  templates = messenger.templates
  messenger.dispatch(templates) if templates.present?
end