Class: Pageflow::UserPolicy::Scope
- Inherits:
-
Scope
- Object
- Scope
- Pageflow::UserPolicy::Scope
- Defined in:
- app/policies/pageflow/user_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
Instance Attribute Details
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
4 5 6 |
# File 'app/policies/pageflow/user_policy.rb', line 4 def scope @scope end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
4 5 6 |
# File 'app/policies/pageflow/user_policy.rb', line 4 def user @user end |
Instance Method Details
#resolve ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/policies/pageflow/user_policy.rb', line 11 def resolve if user.admin? scope.all else manager_accounts_ids = AccountPolicy::Scope .new(@user, Account).member_addable.map(&:id) scope.joins(:memberships) .where('pageflow_memberships.entity_type = \'Pageflow::Account\'') .where(membership_in_managed_account(manager_accounts_ids)).distinct end end |