Exception: Authz::Controllers::AuthorizationManager::NotAuthorized

Inherits:
StandardError
  • Object
show all
Defined in:
lib/authz/controllers/authorization_manager.rb

Overview

Error that will be raised if a user is not authorized

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ NotAuthorized

Returns a new instance of NotAuthorized.



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/authz/controllers/authorization_manager.rb', line 42

def initialize(options = {})
  @rolable = options.fetch :rolable
  @controller = options.fetch :controller
  @action = options.fetch :action
  @instance = options.fetch(:instance, nil)

  msg = "#{rolable.class} #{rolable.id} " \
            'does not have a role that allows him to ' \
            "#{controller}##{action}"

  if instance.present?
    msg += " on #{instance}."
  end

  super(msg)
end

Instance Attribute Details

#actionObject (readonly)



41
42
43
# File 'lib/authz/controllers/authorization_manager.rb', line 41

def action
  @action
end

#controllerObject (readonly)



41
42
43
# File 'lib/authz/controllers/authorization_manager.rb', line 41

def controller
  @controller
end

#instanceObject (readonly)



41
42
43
# File 'lib/authz/controllers/authorization_manager.rb', line 41

def instance
  @instance
end

#rolableObject (readonly)



41
42
43
# File 'lib/authz/controllers/authorization_manager.rb', line 41

def rolable
  @rolable
end