Class: Pageflow::AccountMemberQuery::Scope
- Inherits:
-
Object
- Object
- 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
#initialize(account, scope = User.all) ⇒ Scope
Create scope that can limit base scope to account members at or above a given role
19 20 21 22 |
# File 'app/models/pageflow/account_member_query.rb', line 19 def initialize(account, scope = User.all) @account = account @scope = scope end |
Instance Attribute Details
#account ⇒ Pageflow::Account (readonly)
Account whose members we scope
6 7 8 |
# File 'app/models/pageflow/account_member_query.rb', line 6 def account @account end |
#scope ⇒ ActiveRecord::Relation<User> (readonly)
Base scope which is further scoped according to account role
10 11 12 |
# File 'app/models/pageflow/account_member_query.rb', line 10 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
30 31 32 33 |
# File 'app/models/pageflow/account_member_query.rb', line 30 def with_role_at_least(role) scope.joins(memberships_for_account_with_at_least_role(role)) .where(membership_is_present) end |