Class: Vert::Authorization::DynamicPolicy::Scope
- Inherits:
-
Object
- Object
- Vert::Authorization::DynamicPolicy::Scope
- Defined in:
- lib/vert/authorization/dynamic_policy.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#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, context = {}) ⇒ Scope
constructor
A new instance of Scope.
- #resolve ⇒ Object
Constructor Details
#initialize(user, scope, context = {}) ⇒ Scope
Returns a new instance of Scope.
69 70 71 72 73 |
# File 'lib/vert/authorization/dynamic_policy.rb', line 69 def initialize(user, scope, context = {}) @user = user @scope = scope @context = context end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
67 68 69 |
# File 'lib/vert/authorization/dynamic_policy.rb', line 67 def context @context end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
67 68 69 |
# File 'lib/vert/authorization/dynamic_policy.rb', line 67 def scope @scope end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
67 68 69 |
# File 'lib/vert/authorization/dynamic_policy.rb', line 67 def user @user end |
Instance Method Details
#resolve ⇒ Object
75 76 77 78 79 80 81 |
# File 'lib/vert/authorization/dynamic_policy.rb', line 75 def resolve if PermissionResolver.(user, "#{resource_name}.list", context) own_records_only? ? scope.where(created_by: user.id) : scope.all else scope.none end end |