Exception: Bali::AuthorizationError
- Defined in:
- lib/bali/foundations/exceptions/authorization_error.rb
Overview
Error that will be raised when subtarget cannot do something he wanted to do, or when subtarget do something he should not be allowed to do.
Instance Attribute Summary collapse
-
#auth_level ⇒ Object
Returns the value of attribute auth_level.
-
#operation ⇒ Object
Returns the value of attribute operation.
-
#role ⇒ Object
Returns the value of attribute role.
-
#subtarget ⇒ Object
it may be nil, depends on whether rule checking is using symbol/user.
-
#target ⇒ Object
whether a class or an object.
Instance Method Summary collapse
Instance Attribute Details
#auth_level ⇒ Object
Returns the value of attribute auth_level.
5 6 7 |
# File 'lib/bali/foundations/exceptions/authorization_error.rb', line 5 def auth_level @auth_level end |
#operation ⇒ Object
Returns the value of attribute operation.
4 5 6 |
# File 'lib/bali/foundations/exceptions/authorization_error.rb', line 4 def operation @operation end |
#role ⇒ Object
Returns the value of attribute role.
6 7 8 |
# File 'lib/bali/foundations/exceptions/authorization_error.rb', line 6 def role @role end |
#subtarget ⇒ Object
it may be nil, depends on whether rule checking is using symbol/user
9 10 11 |
# File 'lib/bali/foundations/exceptions/authorization_error.rb', line 9 def subtarget @subtarget end |
#target ⇒ Object
whether a class or an object
12 13 14 |
# File 'lib/bali/foundations/exceptions/authorization_error.rb', line 12 def target @target end |
Instance Method Details
#target_proper_class ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/bali/foundations/exceptions/authorization_error.rb', line 14 def target_proper_class if target.is_a?(Class) target else target.class end end |
#to_s ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/bali/foundations/exceptions/authorization_error.rb', line 22 def to_s role = humanise_value(self.role) operation = humanise_value(self.operation) auth_level = humanise_value(self.auth_level) if auth_level == :can "Role #{role} is not allowed to perform operation `#{operation}` on #{target_proper_class}" else "Role #{role} is allowed to perform operation `#{operation}` on #{target_proper_class}" end end |