Sha256: 8742bd0a55dbb3d45733e1a38a0a1dd98619f3beaecc25de3ee48dbdab60fd23

Contents?: true

Size: 1.41 KB

Versions: 20

Compression:

Stored size: 1.41 KB

Contents

# #
# AUTO GENERATED MODEL
# This model was auto generated by the CanvasSync Gem.
# You can customize it as needed, but make sure you test
# any changes you make to the auto generated methods.
#


class Enrollment < ApplicationRecord
  include CanvasSync::Record
  include CanvasSync::Concerns::ApiSyncable

  canvas_sync_features :defaults

  # include CanvasSync::Concerns::LiveEventSync
  # after_process_live_event do
  #   if user.nil?
  #     u = User.new(canvas_id: canvas_user_id)
  #     u.sync_from_api
  #   end
  #   if course.nil?
  #     c = Course.new(canvas_id: canvas_course_id)
  #     c.sync_from_api
  #   end
  # end

  validates :canvas_id, uniqueness: true, presence: true
  belongs_to :user, primary_key: :canvas_id, foreign_key: :canvas_user_id, optional: true
  belongs_to :role, primary_key: :canvas_id, foreign_key: :canvas_role_id, optional: true
  belongs_to :course, primary_key: :canvas_id, foreign_key: :canvas_course_id, optional: true
  belongs_to :section, primary_key: :canvas_id, foreign_key: :canvas_section_id, optional: true

  api_syncable({
    canvas_id: :id,
    canvas_course_id: :course_id,
    course_sis_id: :sis_course_id,
    canvas_user_id: :user_id,
    user_sis_id: :sis_user_id,
    canvas_section_id: :course_section_id,
    role: :role,
    canvas_role_id: :role_id,
    base_role_type: :type,
    workflow_state: :enrollment_state,
  }, -> (api) { api.enrollment("self", canvas_id) })
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
canvas_sync-0.22.9 spec/dummy/app/models/enrollment.rb
canvas_sync-0.22.8 spec/dummy/app/models/enrollment.rb
canvas_sync-0.22.6 spec/dummy/app/models/enrollment.rb
canvas_sync-0.22.5 spec/dummy/app/models/enrollment.rb
canvas_sync-0.22.4 spec/dummy/app/models/enrollment.rb
canvas_sync-0.22.3 spec/dummy/app/models/enrollment.rb
canvas_sync-0.22.2 spec/dummy/app/models/enrollment.rb
canvas_sync-0.22.1 spec/dummy/app/models/enrollment.rb
canvas_sync-0.22.0 spec/dummy/app/models/enrollment.rb
canvas_sync-0.22.0.beta8 spec/dummy/app/models/enrollment.rb
canvas_sync-0.22.0.beta7 spec/dummy/app/models/enrollment.rb
canvas_sync-0.22.0.beta6 spec/dummy/app/models/enrollment.rb
canvas_sync-0.22.0.beta5 spec/dummy/app/models/enrollment.rb
canvas_sync-0.22.0.beta4 spec/dummy/app/models/enrollment.rb
canvas_sync-0.22.0.beta3 spec/dummy/app/models/enrollment.rb
canvas_sync-0.22.0.beta2 spec/dummy/app/models/enrollment.rb
canvas_sync-0.22.0.beta1 spec/dummy/app/models/enrollment.rb
canvas_sync-0.21.1 spec/dummy/app/models/enrollment.rb
canvas_sync-0.21.1.beta1 spec/dummy/app/models/enrollment.rb
canvas_sync-0.21.0 spec/dummy/app/models/enrollment.rb