Sha256: b8676213457809a6c371e91d96af2ea89765b0d1a887842ca403e9c1a92c0ac4

Contents?: true

Size: 708 Bytes

Versions: 42

Compression:

Stored size: 708 Bytes

Contents

<%= autogenerated_model_warning %>

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 lib/canvas_sync/generators/templates/models/role.rb
canvas_sync-0.9.3 lib/canvas_sync/generators/templates/models/role.rb
canvas_sync-0.9.2 lib/canvas_sync/generators/templates/models/role.rb
canvas_sync-0.9.1 lib/canvas_sync/generators/templates/models/role.rb
canvas_sync-0.9.0 lib/canvas_sync/generators/templates/models/role.rb
canvas_sync-0.8.4 lib/canvas_sync/generators/templates/models/role.rb
canvas_sync-0.8.3 lib/canvas_sync/generators/templates/models/role.rb
canvas_sync-0.8.2 lib/canvas_sync/generators/templates/models/role.rb
canvas_sync-0.8.1 lib/canvas_sync/generators/templates/models/role.rb
canvas_sync-0.8.0 lib/canvas_sync/generators/templates/models/role.rb
canvas_sync-0.7.3 lib/canvas_sync/generators/templates/models/role.rb
canvas_sync-0.7.2 lib/canvas_sync/generators/templates/models/role.rb
canvas_sync-0.7.1 lib/canvas_sync/generators/templates/models/role.rb
canvas_sync-0.7.0 lib/canvas_sync/generators/templates/models/role.rb
canvas_sync-0.6.4 lib/canvas_sync/generators/templates/models/role.rb
canvas_sync-0.6.3 lib/canvas_sync/generators/templates/models/role.rb
canvas_sync-0.6.2 lib/canvas_sync/generators/templates/models/role.rb
canvas_sync-0.6.1 lib/canvas_sync/generators/templates/models/role.rb
canvas_sync-0.6.0 lib/canvas_sync/generators/templates/models/role.rb
canvas_sync-0.5.4 lib/canvas_sync/generators/templates/models/role.rb