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.
94 95 96 97 |
# File 'app/models/pageflow/entry_role_query.rb', line 94 def initialize(user, entry) @user = user @entry = entry end |
Instance Method Details
#has_at_least_account_role?(role) ⇒ Boolean
109 110 111 112 113 114 |
# File 'app/models/pageflow/entry_role_query.rb', line 109 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
99 100 101 102 103 104 105 106 107 |
# File 'app/models/pageflow/entry_role_query.rb', line 99 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 |