Class: LiveEvents::EnrollmentEvent

Inherits:
CanvasSync::LiveEvents::BaseHandler show all
Defined in:
lib/canvas_sync/generators/templates/services/live_events/enrollment_event.rb

Instance Attribute Summary collapse

Attributes inherited from CanvasSync::LiveEvents::BaseHandler

#metadata, #payload, #raw_payload

Attributes inherited from CanvasSync::Job

#job_log

Instance Method Summary collapse

Methods inherited from CanvasSync::LiveEvents::BaseHandler

#perform

Methods inherited from CanvasSync::Job

#create_job_log, #report_checker_wait_time, #update_or_create_model

Instance Attribute Details

#enrollmentObject

Returns the value of attribute enrollment.



5
6
7
# File 'lib/canvas_sync/generators/templates/services/live_events/enrollment_event.rb', line 5

def enrollment
  @enrollment
end

Instance Method Details

#processObject



7
8
9
10
11
12
13
14
15
# File 'lib/canvas_sync/generators/templates/services/live_events/enrollment_event.rb', line 7

def process()
  @enrollment = Enrollment.where(canvas_id: local_canvas_id(payload[:enrollment_id])).first_or_initialize
  enrollment.canvas_course_id = local_canvas_id(payload[:course_id])
  enrollment.sync_from_api
  if enrollment.user.nil?
    u = User.new(canvas_id: enrollment.canvas_user_id)
    u.sync_from_api
  end
end