Class: Faalis::ApplicationPolicy::Scope
- Inherits:
-
Object
- Object
- Faalis::ApplicationPolicy::Scope
- Defined in:
- app/policies/faalis/application_policy.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.
41 42 43 44 |
# File 'app/policies/faalis/application_policy.rb', line 41 def initialize(user, scope) @user = user @scope = scope end |
Instance Attribute Details
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
39 40 41 |
# File 'app/policies/faalis/application_policy.rb', line 39 def scope @scope end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
39 40 41 |
# File 'app/policies/faalis/application_policy.rb', line 39 def user @user end |
Instance Method Details
#resolve ⇒ Object
46 47 48 49 50 51 52 |
# File 'app/policies/faalis/application_policy.rb', line 46 def resolve if @user.has_ownership?(scope) scope.where(user: @user) else scope end end |