Sha256: 8b05ce9d3a755978eec6fe47b813e81ada84fbbe596fe34d488672f2fa82f16e

Contents?: true

Size: 592 Bytes

Versions: 6

Compression:

Stored size: 592 Bytes

Contents

# frozen_string_literal: true

require 'ditty/policies/application_policy'

module Ditty
  class AuditLogPolicy < ApplicationPolicy
    def create?
      false
    end

    def list?
      user&.super_admin?
    end

    def read?
      user&.super_admin?
    end

    def update?
      false
    end

    def delete?
      false
    end

    def permitted_attributes
      %i[action details]
    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

6 entries across 6 versions & 1 rubygems

Version Path
ditty-0.11.1 lib/ditty/policies/audit_log_policy.rb
ditty-0.10.2 lib/ditty/policies/audit_log_policy.rb
ditty-0.10.1 lib/ditty/policies/audit_log_policy.rb
ditty-0.9.1 lib/ditty/policies/audit_log_policy.rb
ditty-0.9.0 lib/ditty/policies/audit_log_policy.rb
ditty-0.8.0 lib/ditty/policies/audit_log_policy.rb