Class: Strongbolt::Unauthorized
- Inherits:
-
StrongboltError
- Object
- Strongbolt::Unauthorized
- Defined in:
- lib/strongbolt/errors.rb
Overview
Copy & Paste of Grant Error
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(*args) ⇒ Unauthorized
constructor
A new instance of Unauthorized.
- #to_s ⇒ Object
Constructor Details
#initialize(*args) ⇒ Unauthorized
Returns a new instance of Unauthorized.
10 11 12 13 14 15 16 |
# File 'lib/strongbolt/errors.rb', line 10 def initialize(*args) if args.size == 3 @user, @action, @model = args else @message = args[0] end end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
8 9 10 |
# File 'lib/strongbolt/errors.rb', line 8 def action @action end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
8 9 10 |
# File 'lib/strongbolt/errors.rb', line 8 def model @model end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
8 9 10 |
# File 'lib/strongbolt/errors.rb', line 8 def user @user end |
Instance Method Details
#to_s ⇒ Object
18 19 20 21 22 23 24 25 26 |
# 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 |