module Rolypoly::ControllerRoleDSL
Public Class Methods
included(sub)
click to toggle source
# File lib/rolypoly/controller_role_dsl.rb, line 7 def self.included(sub) if sub.respond_to? :before_filter sub.before_filter(:rolypoly_check_role_access!) elsif sub.respond_to? :before_action sub.before_action(:rolypoly_check_role_access!) end if sub.respond_to? :rescue_from sub.rescue_from(FailedRoleCheckError) do respond_to do |f| f.html { render plain: "Not Authorized", status: 401 } f.json { render json: { error: "Not Authorized" }, status: 401 } f.xml { render xml: { error: "Not Authorized" }, status: 401 } end end end sub.send(:include, RoleDSL) sub.extend(ClassMethods) sub.send(:include, InstanceMethods) end