Commit aaf30ca9b0076421c291172cb250c9e43c649f95
Minor fix in ActiveRecord::Authorization, following Santilin request
| |   |
| 67 | 67 | agent = options[:to] || Anyone.current |
| 68 | 68 | |
| 69 | 69 | if authorization_cache[agent][permission].nil? |
| authorization_cache[agent][permission] = |
| authorization_methods_eval(agent, permission) |
| authorization_eval = authorization_methods_eval(agent, permission) |
| # Deny by default |
| authorization_eval = false if authorization_eval.nil? |
| # Cache the evalutation for better performance |
| authorization_cache[agent][permission] = authorization_eval |
| 72 | 75 | else |
| 73 | 76 | authorization_cache[agent][permission] |
| 74 | 77 | end |
| … | … | |
| 86 | 86 | authorize?(permission, options) |
| 87 | 87 | end |
| 88 | 88 | |
| private |
|
| 89 | 91 | # Authorization Cache |
| def authorization_cache |
| def authorization_cache #:nodoc: |
| 91 | 93 | @authorization_cache ||= Hash.new{ |agent, permission| agent[permission] = Hash.new } |
| 92 | 94 | end |
| 93 | 95 | |
| private |
|
| 96 | 96 | def authorization_methods_eval(agent, permission) #:nodoc: |
| 97 | 97 | self.class.authorization_methods.each do |m| |
| 98 | 98 | auth_method_eval = |
| … | … | |
| 108 | 108 | return auth_method_eval unless auth_method_eval.nil? |
| 109 | 109 | end |
| 110 | 110 | |
| false |
| nil |
| 112 | 112 | end |
| 113 | 113 | end |
| 114 | 114 | end |