Module: Shamu::Security::Roles
Overview
Class Method Summary collapse
-
.expand_roles(*roles) ⇒ Array<Symbol>
Expand the given roles to include the roles that they have inherited.
-
.role(name, inherits: nil, scopes: nil)
Define a named role.
-
.role_defined?(role) ⇒ Boolean
True if the role has been defined.
-
.roles ⇒ Hash
The named roles defined on the class.
Class Method Details
.expand_roles(*roles) ⇒ Array<Symbol>
Expand the given roles to include the roles that they have inherited.
30 31 32 |
# File 'lib/shamu/security/roles.rb', line 30 def ( *roles ) ( roles, Set.new ).to_a end |
.role(name, inherits: nil, scopes: nil)
This method returns an undefined value.
Define a named role.
23 24 25 |
# File 'lib/shamu/security/roles.rb', line 23 def role( name, inherits: nil, scopes: nil ) roles[ name.to_sym ] = { inherits: Array( inherits ), scopes: Array( scopes ) } end |
.role_defined?(role) ⇒ Boolean
Returns true if the role has been defined.
36 37 38 |
# File 'lib/shamu/security/roles.rb', line 36 def role_defined?( role ) roles.key?( role.to_sym ) end |
.roles ⇒ Hash
Returns the named roles defined on the class.
12 13 14 |
# File 'lib/shamu/security/roles.rb', line 12 def roles @roles ||= {} end |