Class: Authorization::ControllerHelper
- Defined in:
- lib/role-authz/authorization/controller_helper.rb
Instance Method Summary collapse
- #actions_for(role) ⇒ Object
- #allow(*the_actions) ⇒ Object
- #for_roles(*the_roles) ⇒ Object (also: #for_role)
-
#initialize ⇒ ControllerHelper
constructor
A new instance of ControllerHelper.
Constructor Details
#initialize ⇒ ControllerHelper
Returns a new instance of ControllerHelper.
3 4 5 6 |
# File 'lib/role-authz/authorization/controller_helper.rb', line 3 def initialize @working_roles = [] @permissions_list = {} end |
Instance Method Details
#actions_for(role) ⇒ Object
25 26 27 |
# File 'lib/role-authz/authorization/controller_helper.rb', line 25 def actions_for(role) @permissions_list[role] || [] end |
#allow(*the_actions) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/role-authz/authorization/controller_helper.rb', line 15 def allow(*the_actions) raise NoCurrentForRoleStatement unless !@working_roles.empty? @working_roles.each do |current_role| @permissions_list[current_role] ||= [] @permissions_list[current_role] += the_actions end @working_roles.clear self end |
#for_roles(*the_roles) ⇒ Object Also known as: for_role
8 9 10 11 12 |
# File 'lib/role-authz/authorization/controller_helper.rb', line 8 def for_roles(*the_roles) raise OpenForRoleStatement unless @working_roles.empty? @working_roles = the_roles.clone self end |