Module: Authorizr::Controller::ClassMethods
- Defined in:
- lib/authorizr/controller.rb
Instance Method Summary collapse
-
#authorize(&block) ⇒ Object
these methods will be called from the Class level, not the instance level.
- #authorize_all ⇒ Object
-
#create_authblock_catalog ⇒ Object
build maintain a catalog of the auth/unauth blocks provided by the child controllers.
-
#manually_authorize(params = {}) ⇒ Object
a hook for other object to authorize from outside the request object.
- #unauthorized(&block) ⇒ Object
Instance Method Details
#authorize(&block) ⇒ Object
these methods will be called from the Class level, not the instance level
30 31 32 |
# File 'lib/authorizr/controller.rb', line 30 def &block @@authorization_blocks[self.to_s] = block unless block.nil? end |
#authorize_all ⇒ Object
5 6 7 |
# File 'lib/authorizr/controller.rb', line 5 def before_filter :authorize! end |
#create_authblock_catalog ⇒ Object
build maintain a catalog of the auth/unauth blocks provided by the child controllers
39 40 41 42 |
# File 'lib/authorizr/controller.rb', line 39 def create_authblock_catalog @@authorization_blocks = {} @@failure_blocks = {} end |
#manually_authorize(params = {}) ⇒ Object
a hook for other object to authorize from outside the request object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/authorizr/controller.rb', line 10 def params={} params[:user] ||= nil params[:resource] ||= nil params[:action] ||= nil auth_block = @@authorization_blocks[self.to_s] if auth_block.nil? = false else = auth_block.call({ :user => params[:user], :resource => params[:resource], :action => params[:action], :params => {}, :model => params[:resource].class }) end end |
#unauthorized(&block) ⇒ Object
34 35 36 |
# File 'lib/authorizr/controller.rb', line 34 def &block @@failure_blocks[self.to_s] = block unless block.nil? end |