Sha256: d2bb009f1647989b396e2f131072af798112e82da6e35d8d94f1a2a8f9dc04b5
Contents?: true
Size: 901 Bytes
Versions: 27
Compression:
Stored size: 901 Bytes
Contents
# <%= autogenerated_event_warning %> module LiveEvents class SyllabusEvent < LiveEvents::BaseEvent # The following is provided in the live events call: # { # course_id: course.global_id, # syllabus_body: LiveEvents.truncate(course.syllabus_body), # old_syllabus_body: LiveEvents.truncate(old_syllabus_body) # } # def perform(event_payload) super attrs = { course_id: course.try(:id), syllabus_body: payload[:syllabus_body], } create_or_update(attrs) end private def create_or_update(attrs) syllabus = Syllabus.where(course_id: attrs[:course_id]).first_or_initialize syllabus.body = attrs[:syllabus_body] # Syllabus Body can get truncated by live events syllabus.save! end def course Course.find_by(canvas_course_id: local_canvas_id(payload[:course_id])) end end end
Version data entries
27 entries across 27 versions & 1 rubygems