Class: Itsf::Backend::DashboardPolicy

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dashboardObject

Returns the value of attribute dashboard

Returns:

  • (Object)

    the current value of dashboard



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

def dashboard
  @dashboard
end

#userObject

Returns the value of attribute user

Returns:

  • (Object)

    the current value of user



2
3
4
# File 'app/policies/itsf/backend/dashboard_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
# File 'app/policies/itsf/backend/dashboard_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) : true
  if allowed
    Rails.logger.info "Allowed access to #{permission_identifier} for #{user}"
  else
    Rails.logger.info "Denied access to #{permission_identifier} for #{user}"
  end
  allowed
end