Class: AccessAllow::Roles

Inherits:
Object
  • Object
show all
Defined in:
lib/access_allow/roles.rb

Class Method Summary collapse

Class Method Details

.for?(type, role) ⇒ Boolean

Check roles are valid for specific user types

Returns:

  • (Boolean)


13
14
15
# File 'lib/access_allow/roles.rb', line 13

def for?(type, role)
  roles_for(type).include?(role.to_sym)
end

.humanized_name(type, role) ⇒ Object

Get a human readable version of the role key



7
8
9
# File 'lib/access_allow/roles.rb', line 7

def humanized_name(type, role)
  I18n.t("abilities.#{type}.roles.#{role}")
end

.roles_for(type) ⇒ Object



17
18
19
# File 'lib/access_allow/roles.rb', line 17

def roles_for(type)
  configuration[type.to_sym]&.keys || []
end