Class: Ibrain::RoleConfiguration
- Inherits:
-
Object
- Object
- Ibrain::RoleConfiguration
- Defined in:
- lib/ibrain/core/role_configuration.rb
Overview
A class responsible for associating Role with a list of permission sets.
Defined Under Namespace
Classes: Role
Instance Attribute Summary collapse
-
#roles ⇒ Object
Returns the value of attribute roles.
Instance Method Summary collapse
-
#activate_permissions!(ability, user) ⇒ Object
Given a CanCan::Ability, and a user, determine what permissions sets can be activated on the ability, then activate them.
-
#assign_permissions(role_name, permission_sets) ⇒ Object
Assign permission sets for a Role that has the name of role_name.
Instance Attribute Details
#roles ⇒ Object
Returns the value of attribute roles.
30 31 32 |
# File 'lib/ibrain/core/role_configuration.rb', line 30 def roles @roles end |
Instance Method Details
#activate_permissions!(ability, user) ⇒ Object
Given a CanCan::Ability, and a user, determine what permissions sets can be activated on the ability, then activate them.
This performs can/cannot declarations on the ability, and can modify its internal permissions.
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/ibrain/core/role_configuration.rb', line 40 def (ability, user) ibrain_roles = ['default'] | user.roles.map(&:name) = Set.new ibrain_roles.each do |role_name| |= roles[role_name]. end .each do || .new(ability).activate! end end |
#assign_permissions(role_name, permission_sets) ⇒ Object
Assign permission sets for a Ibrain::Role that has the name of role_name
65 66 67 68 69 70 |
# File 'lib/ibrain/core/role_configuration.rb', line 65 def (role_name, ) name = role_name.to_s roles[name]..concat roles[name] end |