Module: Permit::ControllerExtensions::PermitInstanceMethods
- Defined in:
- lib/permit/controller.rb
Instance Method Summary (collapse)
-
- (false) access_denied
protected
Called by #check_authorizations when a person is not authorized to access the current action.
-
- (Boolean) allowed?(*args)
protected
Determines if a person is allowed access by evaluating rules for a controller/action, or for a custom rule.
-
- (Boolean) authorized?(roles, resources)
protected
Shortcut for current_person#authorized?.
-
- (Object) check_authorizations
protected
Evaluates the Permit authorization rules for the current person on the current action.
-
- (Boolean) denied?(*args)
protected
Determines if a person is denied access by evaluating rules for a controller/action, or for a custom rule.
-
- (Object) reset_permit_core
protected
Needed to reset the core models in development mode as they were defined in the initializer for Permit.
Instance Method Details
- (false) access_denied (protected)
Called by #check_authorizations when a person is not authorized to access the current action. It calls render_optional_error_file(401) on the controller, to render a Not Authorized error.
If #access_denied is already defined on the superclass, or redefined in the current controller then that will be called instead.
70 71 72 73 |
# File 'lib/permit/controller.rb', line 70 def access_denied defined?(super) ? super : render_optional_error_file(401) return false end |
- (Boolean) allowed?(roles, options = {}) (protected) - (Boolean) allowed?(options) (protected)
Determines if a person is allowed access by evaluating rules for a controller/action, or for a custom rule.
112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/permit/controller.rb', line 112 def allowed?(*args) = args. if .has_key? :action name = [:controller] klass = (name ? "#{name}_controller".camelize.constantize : self) klass.permit_rules.permitted? , [:action], binding else rule = PermitRule.new args[0], rule.matches? , binding end end |
- (Boolean) authorized?(roles, resources) (protected)
Shortcut for current_person#authorized?. If the current person is a guest this will automatically return false.
For information on the parameters for this method see Models::PersonExtensions::PersonInstanceMethods#authorized?
162 163 164 |
# File 'lib/permit/controller.rb', line 162 def (roles, resources) .guest? ? false : .(roles, resources) end |
- (Object) check_authorizations (protected)
Evaluates the Permit authorization rules for the current person on the current action. If the person is not permitted #access_denied will be called.
78 79 80 81 |
# File 'lib/permit/controller.rb', line 78 def return access_denied unless self.permit_rules.permitted?(, params[:action].to_sym, binding) true end |
- (Boolean) denied?(roles, options = {}) (protected) - (Boolean) denied?(options) (protected)
Determines if a person is denied access by evaluating rules for a controller/action, or for a custom rule.
153 154 155 |
# File 'lib/permit/controller.rb', line 153 def denied?(*args) !allowed? *args end |
- (Object) reset_permit_core (protected)
Needed to reset the core models in development mode as they were defined in the initializer for Permit.
57 58 59 60 |
# File 'lib/permit/controller.rb', line 57 def reset_permit_core Permit::Config.reset_core_models return true end |