peimelo/controlled_health_api

View on GitHub
app/policies/reference_policy.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
91%
class ReferencePolicy < ApplicationPolicy
  class Scope < Scope
    def resolve
      if user&.admin?
        scope.all
      else
        raise Pundit::NotAuthorizedError
      end
    end
  end

  def create?
    user&.admin?
  end

  def update?
    user&.admin?
  end

  def destroy?
    user&.admin?
  end
end