Sha256: 35a5eb22a65298a69c5c50fa7122ba0408f53fb6b3450febae194e883329858e

Contents?: true

Size: 605 Bytes

Versions: 17

Compression:

Stored size: 605 Bytes

Contents

module Itsf::Backend
  class EnginePolicy < Struct.new(:user, :engine)
    def access?
      permission_identifier = self.class.name.gsub('Policy', '').underscore
      allowed = user.respond_to?(:allowed_to?) ? user.allowed_to?(permission_identifier) : false

      if allowed
        Rails.logger.debug "User #{user.try_all(*Itsf::Backend.resource_title_methods)} is allowed to access #{permission_identifier}"
      else
        Rails.logger.debug "User #{user.try_all(*Itsf::Backend.resource_title_methods)} is not allowed to access #{permission_identifier}"
      end
      allowed
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
itsf_backend-5.0.0.pre app/policies/itsf/backend/engine_policy.rb
itsf_backend-4.2.3 app/policies/itsf/backend/engine_policy.rb
itsf_backend-4.2.2 app/policies/itsf/backend/engine_policy.rb
itsf_backend-4.2.1 app/policies/itsf/backend/engine_policy.rb
itsf_backend-4.2.0 app/policies/itsf/backend/engine_policy.rb
itsf_backend-4.0.1 app/policies/itsf/backend/engine_policy.rb
itsf_backend-4.0.0 app/policies/itsf/backend/engine_policy.rb
itsf_backend-3.1.1 app/policies/itsf/backend/engine_policy.rb
itsf_backend-3.1.0 app/policies/itsf/backend/engine_policy.rb
itsf_backend-3.0.7 app/policies/itsf/backend/engine_policy.rb
itsf_backend-3.0.6 app/policies/itsf/backend/engine_policy.rb
itsf_backend-3.0.5 app/policies/itsf/backend/engine_policy.rb
itsf_backend-3.0.4 app/policies/itsf/backend/engine_policy.rb
itsf_backend-3.0.3 app/policies/itsf/backend/engine_policy.rb
itsf_backend-3.0.2 app/policies/itsf/backend/engine_policy.rb
itsf_backend-3.0.1 app/policies/itsf/backend/engine_policy.rb
itsf_backend-3.0.0 app/policies/itsf/backend/engine_policy.rb