Sha256: b81f80b9db21ddc8130d36bd7a992f677c716c64ca10e10203a3cb8de89c62a4

Contents?: true

Size: 570 Bytes

Versions: 1

Compression:

Stored size: 570 Bytes

Contents

# frozen_string_literal: true

require 'ditty/policies/application_policy'

module Ditty
  class RolePolicy < 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
      [:name]
    end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ditty-0.8.0 lib/ditty/policies/role_policy.rb