Class: Itsf::Backend::EnginePolicy

Inherits:
Struct
  • Object
show all
Defined in:
app/policies/itsf/backend/engine_policy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#engineObject

Returns the value of attribute engine

Returns:

  • (Object)

    the current value of engine



2
3
4
# File 'app/policies/itsf/backend/engine_policy.rb', line 2

def engine
  @engine
end

#userObject

Returns the value of attribute user

Returns:

  • (Object)

    the current value of user



2
3
4
# File 'app/policies/itsf/backend/engine_policy.rb', line 2

def user
  @user
end

Instance Method Details

#access?Boolean

Returns:

  • (Boolean)


3
4
5
6
7
8
9
10
11
12
13
# File 'app/policies/itsf/backend/engine_policy.rb', line 3

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