1
0

user_role_policy.rb 400 B

12345678910111213141516171819
  1. # frozen_string_literal: true
  2. class UserRolePolicy < ApplicationPolicy
  3. def index?
  4. role.can?(:manage_roles)
  5. end
  6. def create?
  7. role.can?(:manage_roles)
  8. end
  9. def update?
  10. role.can?(:manage_roles) && (role.overrides?(record) || role.id == record.id)
  11. end
  12. def destroy?
  13. !record.everyone? && role.can?(:manage_roles) && role.overrides?(record) && role.id != record.id
  14. end
  15. end