class Strongbolt::Unauthorized

Copy & Paste of Grant Error

Attributes

action[R]
model[R]
user[R]

Public Class Methods

new(*args) click to toggle source
# File lib/strongbolt/errors.rb, line 10
def initialize(*args)
  if args.size == 3
    @user, @action, @model = args
  else
    @message = args[0]
  end
end

Public Instance Methods

to_s() click to toggle source
# File lib/strongbolt/errors.rb, line 18
def to_s
  if @message
    @message
  else
    user_str = user.nil? ? 'Anonymous' : "#{user.try(:class).try(:name)}:#{user.try :id}"
    model_str = model.is_a?(Class) ? (model.try :name).to_s : "#{model.try(:class).try(:name)}:#{model.try :id}"
    "#{action} permission not granted to #{user_str} for resource #{model_str}"
  end
end