Module: Authority::Controller::ClassMethods
- Defined in:
- lib/authority/controller.rb
Instance Method Summary collapse
-
#authority_action(action_map) ⇒ Object
Allows defining and overriding a controller’s map of its actions to the model’s authorizer methods.
-
#authority_action_map ⇒ Hash
The controller action to authority action map used for determining which Rails actions map to which authority actions (ex: index to read).
-
#authorize_actions_for(model_class, options = {}) ⇒ Object
Sets up before_filter to ensure user is allowed to perform a given controller action.
Instance Method Details
#authority_action(action_map) ⇒ Object
Allows defining and overriding a controller’s map of its actions to the model’s authorizer methods
37 38 39 |
# File 'lib/authority/controller.rb', line 37 def (action_map) .merge!(action_map.symbolize_keys) end |
#authority_action_map ⇒ Hash
The controller action to authority action map used for determining which Rails actions map to which authority actions (ex: index to read)
45 46 47 |
# File 'lib/authority/controller.rb', line 45 def @authority_action_map ||= Authority.configuration.controller_action_map.dup end |
#authorize_actions_for(model_class, options = {}) ⇒ Object
Sets up before_filter to ensure user is allowed to perform a given controller action
ones and any other options applicable to a before_filter
28 29 30 31 32 |
# File 'lib/authority/controller.rb', line 28 def (model_class, = {}) self. = model_class ([:actions] || {}) before_filter :run_authorization_check, end |