Class: Croods::Policy::Scope
- Inherits:
-
Object
- Object
- Croods::Policy::Scope
- Defined in:
- lib/croods/policy/scope.rb
Instance Method Summary collapse
-
#initialize(tenant:, user:, scope:) ⇒ Scope
constructor
A new instance of Scope.
- #resolve ⇒ Object
Constructor Details
#initialize(tenant:, user:, scope:) ⇒ Scope
Returns a new instance of Scope.
6 7 8 9 10 |
# File 'lib/croods/policy/scope.rb', line 6 def initialize(tenant:, user:, scope:) self.user = user self.scope = scope self.tenant = user&.tenant || tenant end |
Instance Method Details
#resolve ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/croods/policy/scope.rb', line 12 def resolve self.scope = tenant_scope(scope) if Croods.multi_tenancy? return scope if action.public return scope if super? return owner_scope(scope) if owner? scope end |