Class: G5Authenticatable::BasePolicy::BaseScope
- Inherits:
-
Object
- Object
- G5Authenticatable::BasePolicy::BaseScope
- Defined in:
- app/policies/g5_authenticatable/base_policy.rb
Overview
Base class for all authorization scopes
Direct Known Subclasses
G5Updatable::ClientPolicy::Scope, G5Updatable::LocationPolicy::Scope, G5Updatable::SelectableClientPolicy::Scope
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
- #global_role? ⇒ Boolean (also: #has_global_role?)
-
#initialize(user, scope) ⇒ BaseScope
constructor
A new instance of BaseScope.
- #resolve ⇒ Object
Constructor Details
#initialize(user, scope) ⇒ BaseScope
Returns a new instance of BaseScope.
50 51 52 53 |
# File 'app/policies/g5_authenticatable/base_policy.rb', line 50 def initialize(user, scope) @user = user @scope = scope end |
Instance Attribute Details
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
48 49 50 |
# File 'app/policies/g5_authenticatable/base_policy.rb', line 48 def scope @scope end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
48 49 50 |
# File 'app/policies/g5_authenticatable/base_policy.rb', line 48 def user @user end |
Instance Method Details
#global_role? ⇒ Boolean Also known as: has_global_role?
63 64 65 |
# File 'app/policies/g5_authenticatable/base_policy.rb', line 63 def global_role? G5Authenticatable::BasePolicy.new(user, nil).global_role? end |
#resolve ⇒ Object
55 56 57 58 59 60 61 |
# File 'app/policies/g5_authenticatable/base_policy.rb', line 55 def resolve if user.has_role?(:super_admin) scope.all else scope.none end end |