Class: Pageflow::AccountRoleQuery
- Inherits:
-
ApplicationQuery
- Object
- ApplicationQuery
- Pageflow::AccountRoleQuery
- Defined in:
- app/models/pageflow/account_role_query.rb
Overview
Query users for their role on accounts based on role
Defined Under Namespace
Classes: Scope
Instance Method Summary collapse
-
#has_at_least_role?(role) ⇒ Boolean
Return true if there is a membership with at least role for user/account.
-
#initialize(user, account) ⇒ AccountRoleQuery
constructor
Create query that can be used for role comparisons.
Constructor Details
#initialize(user, account) ⇒ AccountRoleQuery
Create query that can be used for role comparisons
47 48 49 50 |
# File 'app/models/pageflow/account_role_query.rb', line 47 def initialize(user, account) @user = user @account = account end |
Instance Method Details
#has_at_least_role?(role) ⇒ Boolean
Return true if there is a membership with at least role for user/account
58 59 60 61 62 63 64 65 66 |
# File 'app/models/pageflow/account_role_query.rb', line 58 def has_at_least_role?(role) @user .memberships .where(role: Roles.at_least(role)) .where('(entity_id = :account_id AND '\ "entity_type = 'Pageflow::Account')", account_id: @account.id) .any? end |