2017-11-04 17:23:11 +00:00
|
|
|
# frozen_string_literal: true
|
2018-02-06 05:43:10 +00:00
|
|
|
|
2017-11-04 17:23:11 +00:00
|
|
|
class AttachmentPolicy < ApplicationPolicy
|
|
|
|
class Scope < Scope
|
|
|
|
def resolve
|
|
|
|
scope.where(attachable: TopicPolicy::Scope.new(user, Topic).resolve)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def index?
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def create?
|
|
|
|
Pundit.policy(user, record.attachable).update?
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy?
|
|
|
|
Pundit.policy(user, record.attachable).update?
|
|
|
|
end
|
|
|
|
end
|