Exception: Grant::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Grant::Error
- Defined in:
- lib/grant/error.rb
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) ⇒ Error
constructor
A new instance of Error.
- #to_s ⇒ Object
Constructor Details
#initialize(*args) ⇒ Error
Returns a new instance of Error.
5 6 7 8 9 10 11 |
# File 'lib/grant/error.rb', line 5 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.
3 4 5 |
# File 'lib/grant/error.rb', line 3 def action @action end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
3 4 5 |
# File 'lib/grant/error.rb', line 3 def model @model end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
3 4 5 |
# File 'lib/grant/error.rb', line 3 def user @user end |
Instance Method Details
#to_s ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/grant/error.rb', line 13 def to_s if @message @message else user_str = user == nil ? 'Anonymous' : "#{user.class.name}:#{user.id}" "#{action} permission not granted to #{user_str} for resource #{model.class.name}:#{model.id}" end end |