Exception: Moat::NotAuthorizedError

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ NotAuthorizedError

Returns a new instance of NotAuthorizedError.



26
27
28
29
30
31
32
33
34
35
# File 'lib/moat.rb', line 26

def initialize(options = {})
  return super if options.is_a?(String)
  @action = options[:action]
  @resource = options[:resource]
  @policy = options[:policy]
  @user = options[:user]

  message = options.fetch(:message) { "unauthorized #{policy.name}##{action} for #{resource}" }
  super(message)
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



24
25
26
# File 'lib/moat.rb', line 24

def action
  @action
end

#policyObject (readonly)

Returns the value of attribute policy.



24
25
26
# File 'lib/moat.rb', line 24

def policy
  @policy
end

#resourceObject (readonly)

Returns the value of attribute resource.



24
25
26
# File 'lib/moat.rb', line 24

def resource
  @resource
end

#userObject (readonly)

Returns the value of attribute user.



24
25
26
# File 'lib/moat.rb', line 24

def user
  @user
end