Class: Jwtauth::Policy::Scope
- Inherits:
-
Object
- Object
- Jwtauth::Policy::Scope
- Defined in:
- lib/jwtauth.rb
Instance Attribute Summary collapse
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(user, scope) ⇒ Scope
constructor
A new instance of Scope.
- #resolve ⇒ Object
Constructor Details
#initialize(user, scope) ⇒ Scope
Returns a new instance of Scope.
467 468 469 470 |
# File 'lib/jwtauth.rb', line 467 def initialize(user, scope) @user = user @scope = scope end |
Instance Attribute Details
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
465 466 467 |
# File 'lib/jwtauth.rb', line 465 def scope @scope end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
465 466 467 |
# File 'lib/jwtauth.rb', line 465 def user @user end |
Instance Method Details
#resolve ⇒ Object
472 473 474 475 476 477 478 479 480 481 482 483 |
# File 'lib/jwtauth.rb', line 472 def resolve case get_level_of_access(Privileges::READ) when LevelsOfAccess::BUSINESS_UNIT scope.where(scope::ForeignKeys::DEPARTMENT_ID => @user.departments[LevelsOfAccess::BUSINESS_UNIT]) when LevelsOfAccess::FAMILY_BU_TREE scope.where(scope::ForeignKeys::DEPARTMENT_ID => @user.departments[LevelsOfAccess::FAMILY_BU_TREE]) when LevelsOfAccess::ORGANIZATION scope.where(scope::ForeignKeys::COMPANY_ID => @user.company_id) else scope.where(scope::ForeignKeys::USER_ID => @user.id) end end |