Sha256: d128c98b5eee836641a62b95c1576eba7d477ac90312a8ea09d49f8b8d728c67

Contents?: true

Size: 586 Bytes

Versions: 10

Compression:

Stored size: 586 Bytes

Contents

# frozen_string_literal: true

require 'proxes/policies/application_policy'

module ProxES
  class RolePolicy < ApplicationPolicy
    def create?
      user && user.super_admin?
    end

    def list?
      create?
    end

    def read?
      create?
    end

    def update?
      read?
    end

    def delete?
      create?
    end

    def permitted_attributes
      [:name]
    end

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
proxes-0.7.0 lib/proxes/policies/role_policy.rb
proxes-0.6.1 lib/proxes/policies/role_policy.rb
proxes-0.6.0 lib/proxes/policies/role_policy.rb
proxes-0.5.2 lib/proxes/policies/role_policy.rb
proxes-0.5.1 lib/proxes/policies/role_policy.rb
proxes-0.5.0 lib/proxes/policies/role_policy.rb
proxes-0.4.4 lib/proxes/policies/role_policy.rb
proxes-0.4.3 lib/proxes/policies/role_policy.rb
proxes-0.4.2 lib/proxes/policies/role_policy.rb
proxes-0.4.1 lib/proxes/policies/role_policy.rb