Class: Pageflow::EntryRoleQuery
- Inherits:
-
ApplicationQuery
- Object
- ApplicationQuery
- Pageflow::EntryRoleQuery
- Defined in:
- app/models/pageflow/entry_role_query.rb
Defined Under Namespace
Classes: Scope
Instance Method Summary collapse
- #has_at_least_account_role?(role) ⇒ Boolean
- #has_at_least_role?(role) ⇒ Boolean
-
#initialize(user, entry) ⇒ EntryRoleQuery
constructor
A new instance of EntryRoleQuery.
Constructor Details
#initialize(user, entry) ⇒ EntryRoleQuery
Returns a new instance of EntryRoleQuery.
74 75 76 77 |
# File 'app/models/pageflow/entry_role_query.rb', line 74 def initialize(user, entry) @user = user @entry = entry end |
Instance Method Details
#has_at_least_account_role?(role) ⇒ Boolean
89 90 91 92 93 94 |
# File 'app/models/pageflow/entry_role_query.rb', line 89 def has_at_least_account_role?(role) @user .memberships .where(role: Roles.at_least(role), entity: @entry.account) .any? end |
#has_at_least_role?(role) ⇒ Boolean
79 80 81 82 83 84 85 86 87 |
# File 'app/models/pageflow/entry_role_query.rb', line 79 def has_at_least_role?(role) @user .memberships .where(role: Roles.at_least(role)) .where("(entity_id = :entry_id AND entity_type = 'Pageflow::Entry') OR " \ "(entity_id = :account_id AND entity_type = 'Pageflow::Account')", entry_id: @entry.id, account_id: @entry.account.id) .any? end |