Sha256: fbc75fc78a3bb8277531aca5f07bf531f666479c1e390cc3b9f510dd3dae3770

Contents?: true

Size: 995 Bytes

Versions: 42

Compression:

Stored size: 995 Bytes

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 Admin < ApplicationRecord
  validates :canvas_admin_id, uniqueness: true, presence: true
  belongs_to :user, primary_key: :canvas_user_id, foreign_key: :canvas_user_id, optional: true
  belongs_to :role, primary_key: :canvas_role_id, foreign_key: :canvas_role_id, optional: true

  def self.create_or_update(admin_params)
    admin = Admin.find_or_initialize_by(canvas_admin_id: admin_params['id'])

    admin.assign_attributes(role_name: admin_params['role'],
                            canvas_role_id: admin_params['role_id'],
                            user_data: admin_params['user'],
                            canvas_user_id: admin_params['user']['id'],
                            workflow_state: admin_params['workflow_state'])

    admin.save! if admin.changed?
    admin
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
canvas_sync-0.9.4 spec/dummy/app/models/admin.rb
canvas_sync-0.9.3 spec/dummy/app/models/admin.rb
canvas_sync-0.9.2 spec/dummy/app/models/admin.rb
canvas_sync-0.9.1 spec/dummy/app/models/admin.rb
canvas_sync-0.9.0 spec/dummy/app/models/admin.rb
canvas_sync-0.8.4 spec/dummy/app/models/admin.rb
canvas_sync-0.8.3 spec/dummy/app/models/admin.rb
canvas_sync-0.8.2 spec/dummy/app/models/admin.rb
canvas_sync-0.8.1 spec/dummy/app/models/admin.rb
canvas_sync-0.8.0 spec/dummy/app/models/admin.rb
canvas_sync-0.7.3 spec/dummy/app/models/admin.rb
canvas_sync-0.7.2 spec/dummy/app/models/admin.rb
canvas_sync-0.7.1 spec/dummy/app/models/admin.rb
canvas_sync-0.7.0 spec/dummy/app/models/admin.rb
canvas_sync-0.6.4 spec/dummy/app/models/admin.rb
canvas_sync-0.6.3 spec/dummy/app/models/admin.rb
canvas_sync-0.6.2 spec/dummy/app/models/admin.rb
canvas_sync-0.6.1 spec/dummy/app/models/admin.rb
canvas_sync-0.6.0 spec/dummy/app/models/admin.rb
canvas_sync-0.5.4 spec/dummy/app/models/admin.rb