Class: Pageflow::AccountMemberQuery::Scope
- Inherits:
-
Pageflow::ApplicationQuery::Scope
- Object
- Pageflow::ApplicationQuery::Scope
- Pageflow::AccountMemberQuery::Scope
- Defined in:
- app/models/pageflow/account_member_query.rb
Instance Attribute Summary collapse
-
#account ⇒ Pageflow::Account
readonly
Account whose members we scope.
-
#scope ⇒ ActiveRecord::Relation<User>
readonly
Base scope which is further scoped according to account role.
Instance Method Summary collapse
-
#initialize(account, scope = User.all) ⇒ Scope
constructor
Create scope that can limit base scope to account members at or above a given role.
-
#with_role_at_least(role) ⇒ ActiveRecord::Relation<User>
Scope to those members from scope on account who have at least role.
Constructor Details
Instance Attribute Details
#account ⇒ Pageflow::Account (readonly)
Account whose members we scope
7 8 9 |
# File 'app/models/pageflow/account_member_query.rb', line 7 def account @account end |
#scope ⇒ ActiveRecord::Relation<User> (readonly)
Base scope which is further scoped according to account role
11 12 13 |
# File 'app/models/pageflow/account_member_query.rb', line 11 def scope @scope end |
Instance Method Details
#with_role_at_least(role) ⇒ ActiveRecord::Relation<User>
Scope to those members from scope on account who have at least role
31 32 33 34 |
# File 'app/models/pageflow/account_member_query.rb', line 31 def with_role_at_least(role) scope.joins(memberships_for_account_with_at_least_role(role)) .where(membership_is_present) end |