Class: MoulinRouge::CanCan::Responder
- Inherits:
-
Object
- Object
- MoulinRouge::CanCan::Responder
- Defined in:
- lib/moulin_rouge/cancan/responder.rb
Overview
A cleaner implementation of CanCan #load_and_authorize_resource method. Everytime you use the #respond_with method, send the given resources to check the authorizations.
Instance Method Summary collapse
-
#initialize(controller, resources, options = {}) ⇒ Responder
constructor
< ActionController::Responder.
- #to_html ⇒ Object
Constructor Details
#initialize(controller, resources, options = {}) ⇒ Responder
< ActionController::Responder
7 8 9 10 |
# File 'lib/moulin_rouge/cancan/responder.rb', line 7 def initialize(controller, resources, ={}) super @skip_authorization = .delete(:skip_authorization) end |
Instance Method Details
#to_html ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/moulin_rouge/cancan/responder.rb', line 12 def to_html resources.each do |resource| action = resources.last == resource ? controller.params[:action].to_sym : :show controller.(action, resource_class_or_instace(resource)) unless skip?(resource) end super # Continue through method chain end |