2019-08-14 09:48:44 +00:00
|
|
|
class InboxPolicy < ApplicationPolicy
|
|
|
|
class Scope
|
|
|
|
attr_reader :user, :scope
|
|
|
|
|
|
|
|
def initialize(user, scope)
|
|
|
|
@user = user
|
|
|
|
@scope = scope
|
|
|
|
end
|
|
|
|
|
|
|
|
def resolve
|
|
|
|
if user.administrator?
|
|
|
|
scope.all
|
|
|
|
elsif user.agent?
|
|
|
|
user.assigned_inboxes
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def index?
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2019-11-30 12:03:42 +00:00
|
|
|
def create?
|
|
|
|
@user.administrator?
|
|
|
|
end
|
|
|
|
|
2019-08-14 09:48:44 +00:00
|
|
|
def destroy?
|
|
|
|
@user.administrator?
|
|
|
|
end
|
|
|
|
end
|