Class: Kindergarten::AccessDenied

Inherits:
CanCan::AccessDenied
  • Object
show all
Defined in:
lib/kindergarten/exceptions.rb

Overview

Signals unallowed access

Instance Method Summary collapse

Constructor Details

#initialize(action, target, opts) ⇒ AccessDenied

Returns a new instance of AccessDenied.



4
5
6
7
8
9
10
11
12
# File 'lib/kindergarten/exceptions.rb', line 4

def initialize(action, target, opts)
  message = opts.delete(:message)
  if message.blank?
    name    = target.is_a?(Class) ? target.name : target.class.name
    message = "You are not allowed to #{action} that #{name.downcase}"
  end

  super(message, action, target)
end