Class: CanvasSync::LiveEvents::ProcessEventJob

Inherits:
Job
  • Object
show all
Defined in:
lib/canvas_sync/live_events/process_event_job.rb

Instance Attribute Summary

Attributes inherited from Job

#job_log

Instance Method Summary collapse

Methods inherited from Job

#create_job_log, #report_checker_wait_time, #update_or_create_model

Instance Method Details

#perform(event) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/canvas_sync/live_events/process_event_job.rb', line 4

def perform(event)
  event = event.with_indifferent_access

  # Support Legacy-Style Event Handlers
  begin
    legacy_handler = "LiveEvents::#{event['metadata']['event_name'].camelcase}Event".constantize
    legacy_handler.perform_later(event)
    return
  rescue LoadError, NameError => e
    Rails.logger.error("Error accessing legacy-style LiveEvents handler #{e}, #{event}")
  end

  handlers = CanvasSync::LiveEvents.registered_handlers
  handlers.each do |h|
    h.call(event)
  rescue => e
    throw e if Rails.env.test?
    Rails.logger.error("LiveEvent Handler raised Error: #{e}")
    Raven.captureException(e) if defined? Raven
  end
end