Sha256: 476cd8cc2136bbce54985bfb74f53eb17cc2958fc0cdc95a7c9d5b9a89d121ce

Contents?: true

Size: 578 Bytes

Versions: 1

Compression:

Stored size: 578 Bytes

Contents

# frozen_string_literal: true

require 'ditty/policies/application_policy'

module ProxES
  class PermissionPolicy < Ditty::ApplicationPolicy
    def create?
      user&.super_admin?
    end

    def list?
      create?
    end

    def read?
      create?
    end

    def update?
      read?
    end

    def delete?
      create?
    end

    def permitted_attributes
      %i[verb pattern index role_id user_id]
    end

    class Scope < Ditty::ApplicationPolicy::Scope
      def resolve
        user&.super_admin? ? scope : scope.where(id: -1)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
proxes-0.10.1 lib/proxes/policies/permission_policy.rb