Exception: Pundit::NotAuthorizedError
- Defined in:
- lib/pundit/error.rb
Overview
Error that will be raised when authorization has failed
Instance Attribute Summary collapse
- #policy ⇒ Object readonly
- #query ⇒ Object readonly
- #record ⇒ Object readonly
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ NotAuthorizedError
constructor
A new instance of NotAuthorizedError.
Constructor Details
#initialize(message) ⇒ NotAuthorizedError #initialize(options) ⇒ NotAuthorizedError
Returns a new instance of NotAuthorizedError.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/pundit/error.rb', line 36 def initialize( = {}) if .is_a? String = else @query = [:query] @record = [:record] @policy = [:policy] = .fetch(:message) do record_name = record.is_a?(Class) ? record.to_s : "this #{record.class}" "not allowed to #{policy.class}##{query} #{record_name}" end end super() end |
Instance Attribute Details
#policy ⇒ Object (readonly)
21 22 23 |
# File 'lib/pundit/error.rb', line 21 def policy @policy end |
#query ⇒ Object (readonly)
15 16 17 |
# File 'lib/pundit/error.rb', line 15 def query @query end |
#record ⇒ Object (readonly)
18 19 20 |
# File 'lib/pundit/error.rb', line 18 def record @record end |