Exception: Pundit::NotAuthorizedError

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

Overview

Error that will be raised when authorization has failed

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ NotAuthorizedError

Returns a new instance of NotAuthorizedError


24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/pundit.rb', line 24

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)


22
23
24
# File 'lib/pundit.rb', line 22

def policy
  @policy
end

#queryObject (readonly)


22
23
24
# File 'lib/pundit.rb', line 22

def query
  @query
end

#recordObject (readonly)


22
23
24
# File 'lib/pundit.rb', line 22

def record
  @record
end