Sha256: ac39366507b5c88cf6bcd2ca8de196490ed75d396430a5898f24177129a7f115

Contents?: true

Size: 867 Bytes

Versions: 42

Compression:

Stored size: 867 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 Role < ApplicationRecord
  validates :canvas_role_id, uniqueness: true, presence: true
  has_many :admins, foreign_key: :canvas_role_id, primary_key: :canvas_role_id

  def self.create_or_update(role_params)
    role = Role.find_or_initialize_by(canvas_role_id: role_params['id'])

    role.assign_attributes(label: role_params['label'],
                           base_role_type: role_params['base_role_type'],
                           account: role_params['account'],
                           permissions: role_params['permissions'],
                           workflow_state: role_params['workflow_state'])

    role.save! if role.changed?
    role
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

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