Class: Pageflow::Admin::EntryTabPolicy
- Inherits:
-
Object
- Object
- Pageflow::Admin::EntryTabPolicy
- Defined in:
- app/policies/pageflow/admin/entry_tab_policy.rb
Overview
Instance Attribute Summary collapse
- #query ⇒ Object readonly
- #tab ⇒ Object readonly
- #user ⇒ Object readonly
Instance Method Summary collapse
-
#initialize(user, tab) ⇒ EntryTabPolicy
constructor
A new instance of EntryTabPolicy.
- #see? ⇒ Boolean
Constructor Details
#initialize(user, tab) ⇒ EntryTabPolicy
Returns a new instance of EntryTabPolicy.
6 7 8 9 10 |
# File 'app/policies/pageflow/admin/entry_tab_policy.rb', line 6 def initialize(user, tab) @user = user @tab = tab @query = EntryRoleQuery.new(user, tab.resource) end |
Instance Attribute Details
#query ⇒ Object (readonly)
4 5 6 |
# File 'app/policies/pageflow/admin/entry_tab_policy.rb', line 4 def query @query end |
#tab ⇒ Object (readonly)
4 5 6 |
# File 'app/policies/pageflow/admin/entry_tab_policy.rb', line 4 def tab @tab end |
#user ⇒ Object (readonly)
4 5 6 |
# File 'app/policies/pageflow/admin/entry_tab_policy.rb', line 4 def user @user end |
Instance Method Details
#see? ⇒ Boolean
12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/policies/pageflow/admin/entry_tab_policy.rb', line 12 def see? if user.admin? true elsif tab.required_account_role query.has_at_least_account_role?(tab.required_account_role) elsif tab.required_role query.has_at_least_role?(tab.required_role) else !tab.admin_only? end end |