Class: Pageflow::Admin::EntryTabPolicy

Inherits:
Object
  • Object
show all
Defined in:
app/policies/pageflow/admin/entry_tab_policy.rb

Overview

Since:

  • 12.2

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, tab) ⇒ EntryTabPolicy

Returns a new instance of EntryTabPolicy.

Since:

  • 12.2



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

#queryObject (readonly)

Since:

  • 12.2



4
5
6
# File 'app/policies/pageflow/admin/entry_tab_policy.rb', line 4

def query
  @query
end

#tabObject (readonly)

Since:

  • 12.2



4
5
6
# File 'app/policies/pageflow/admin/entry_tab_policy.rb', line 4

def tab
  @tab
end

#userObject (readonly)

Since:

  • 12.2



4
5
6
# File 'app/policies/pageflow/admin/entry_tab_policy.rb', line 4

def user
  @user
end

Instance Method Details

#see?Boolean

Returns:

  • (Boolean)

Since:

  • 12.2



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.
    query.(tab.)
  elsif tab.required_role
    query.has_at_least_role?(tab.required_role)
  else
    !tab.admin_only?
  end
end