Class: Yes::Auth::Principals::Role

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/yes/auth/principals/role.rb

Overview

Represents an authorization role that can be assigned to users and resource accesses.

Examples:

Finding the super admin role

Yes::Auth::Principals::Role.super_admin_role

Constant Summary collapse

SUPER_ADMIN_ROLE_NAME =
'admin'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.super_admin_roleYes::Auth::Principals::Role?

Returns the super admin role.

Returns:



30
31
32
# File 'lib/yes/auth/principals/role.rb', line 30

def self.super_admin_role
  find_by(name: SUPER_ADMIN_ROLE_NAME)
end

Instance Method Details

#resource_authorization_nameString?

Returns the role name with colons replaced by underscores.

Returns:

  • (String, nil)

    the role name with colons replaced by underscores



25
26
27
# File 'lib/yes/auth/principals/role.rb', line 25

def resource_authorization_name
  name&.tr(':', '_')
end