Module: Verikloak::Pundit::Delegations

Defined in:
lib/verikloak/pundit/delegations.rb

Overview

Shared role/permission delegations to expose consistent helpers.

Instance Method Summary collapse

Instance Method Details

#has_permission?(perm) ⇒ Boolean

Check whether the user has a mapped permission.

Parameters:

  • perm (String, Symbol)

Returns:

  • (Boolean)


26
# File 'lib/verikloak/pundit/delegations.rb', line 26

def has_permission?(perm) = user.has_permission?(perm) # rubocop:disable Naming/PredicatePrefix

#has_role?(role) ⇒ Boolean

Check whether the user has a realm role.

Parameters:

  • role (String, Symbol)

Returns:

  • (Boolean)


10
# File 'lib/verikloak/pundit/delegations.rb', line 10

def has_role?(role) = user.has_role?(role) # rubocop:disable Naming/PredicatePrefix

#in_group?(group) ⇒ Boolean

Check whether the user belongs to a group (alias to role).

Parameters:

  • group (String, Symbol)

Returns:

  • (Boolean)


15
# File 'lib/verikloak/pundit/delegations.rb', line 15

def in_group?(group) = user.in_group?(group)

#resource_role?(client, role) ⇒ Boolean

Check whether the user has a role for a specific resource client.

Parameters:

  • client (String, Symbol)
  • role (String, Symbol)

Returns:

  • (Boolean)


21
# File 'lib/verikloak/pundit/delegations.rb', line 21

def resource_role?(client, role) = user.resource_role?(client, role)