Exception: Pundit::NotAuthorizedError

Inherits:
Error
  • Object
show all
Defined in:
lib/pundit.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ NotAuthorizedError

Returns a new instance of NotAuthorizedError.



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/pundit.rb', line 16

def initialize(options = {})
  if options.is_a? String
    message = options
  else
    @query  = options[:query]
    @record = options[:record]
    @policy = options[:policy]

    message = options.fetch(:message) { "not allowed to #{query} this #{record.inspect}" }
  end

  super(message)
end

Instance Attribute Details

#policyObject (readonly)

Returns the value of attribute policy.



14
15
16
# File 'lib/pundit.rb', line 14

def policy
  @policy
end

#queryObject (readonly)

Returns the value of attribute query.



14
15
16
# File 'lib/pundit.rb', line 14

def query
  @query
end

#recordObject (readonly)

Returns the value of attribute record.



14
15
16
# File 'lib/pundit.rb', line 14

def record
  @record
end