diff options
Diffstat (limited to 'app/models/agency.rb')
-rw-r--r-- | app/models/agency.rb | 28 |
1 files changed, 0 insertions, 28 deletions
diff --git a/app/models/agency.rb b/app/models/agency.rb index 7ffe489..842e8bd 100644 --- a/app/models/agency.rb +++ b/app/models/agency.rb @@ -3,34 +3,6 @@ # SPDX-License-Identifier: AGPL-3.0-or-later class Agency < ApplicationRecord - include Bitfields - belongs_to :agent belongs_to :user - - bitfield :roles, :observer, :editor, :maintainer, :leader - - class << self - # Grant role in agent to user - def grant(agent, user, role) - r = find_or_create_by(agent: agent, user: user) - r&.public_send("#{role}=", true) && r&.save - end - - # Revoke role in agent from user - def revoke(agent, user, role) - r = find_by(agent: agent, user: user) - r&.public_send("#{role}=", false) && r&.save - end - end - - # Grant role to current user in current agent - def grant(role) - self.class.grant(agent, user, role) - end - - # Revoke role from current user in current agent - def revoke(role) - self.class.revoke(agent, user, role) - end end |