Sha256: d429a5d149c47f9c249a84681659a3478991c3da8828c0c077a595838fe46902

Contents?: true

Size: 987 Bytes

Versions: 23

Compression:

Stored size: 987 Bytes

Contents

# <%= autogenerated_event_warning %>

module LiveEvents
  class CourseEvent < LiveEvents::BaseEvent
    # The following is provided in the live events call:
    # {
    #     course_id: course.global_id,
    #     uuid: course.uuid,
    #     account_id: course.global_account_id,
    #     name: course.name,
    #     created_at: course.created_at,
    #     updated_at: course.updated_at,
    #     workflow_state: course.workflow_state
    # }

    def perform(event_payload)
      super
      attrs = {
        canvas_course_id: local_canvas_id(payload[:course_id]),
        canvas_account_id: local_canvas_id(payload[:account_id]),
        long_name: payload[:name],
        status: payload[:workflow_state],
      }
      create_or_update(attrs)
    end

    private

    def create_or_update(attrs)
      course = Course.where(canvas_course_id: attrs[:canvas_course_id]).first_or_initialize
      course.assign_attributes(attrs)
      course.save!
      course
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
canvas_sync-0.9.4 lib/canvas_sync/generators/templates/services/live_events/course/course_event.rb
canvas_sync-0.9.3 lib/canvas_sync/generators/templates/services/live_events/course/course_event.rb
canvas_sync-0.9.2 lib/canvas_sync/generators/templates/services/live_events/course/course_event.rb
canvas_sync-0.9.1 lib/canvas_sync/generators/templates/services/live_events/course/course_event.rb
canvas_sync-0.9.0 lib/canvas_sync/generators/templates/services/live_events/course/course_event.rb
canvas_sync-0.8.4 lib/canvas_sync/generators/templates/services/live_events/course/course_event.rb
canvas_sync-0.8.3 lib/canvas_sync/generators/templates/services/live_events/course/course_event.rb
canvas_sync-0.8.2 lib/canvas_sync/generators/templates/services/live_events/course/course_event.rb
canvas_sync-0.8.1 lib/canvas_sync/generators/templates/services/live_events/course/course_event.rb
canvas_sync-0.8.0 lib/canvas_sync/generators/templates/services/live_events/course/course_event.rb
canvas_sync-0.7.3 lib/canvas_sync/generators/templates/services/live_events/course/course_event.rb
canvas_sync-0.7.2 lib/canvas_sync/generators/templates/services/live_events/course/course_event.rb
canvas_sync-0.7.1 lib/canvas_sync/generators/templates/services/live_events/course/course_event.rb
canvas_sync-0.7.0 lib/canvas_sync/generators/templates/services/live_events/course/course_event.rb
canvas_sync-0.6.4 lib/canvas_sync/generators/templates/services/live_events/course/course_event.rb
canvas_sync-0.6.3 lib/canvas_sync/generators/templates/services/live_events/course/course_event.rb
canvas_sync-0.6.2 lib/canvas_sync/generators/templates/services/live_events/course/course_event.rb
canvas_sync-0.6.1 lib/canvas_sync/generators/templates/services/live_events/course/course_event.rb
canvas_sync-0.6.0 lib/canvas_sync/generators/templates/services/live_events/course/course_event.rb
canvas_sync-0.5.4 lib/canvas_sync/generators/templates/services/live_events/course/course_event.rb