Class: Locomotive::PagePolicy

Inherits:
ApplicationPolicy show all
Defined in:
app/policies/locomotive/page_policy.rb

Instance Attribute Summary

Attributes inherited from ApplicationPolicy

#membership, #resource

Instance Method Summary collapse

Methods inherited from ApplicationPolicy

#destroy_all?, #initialize, #persisted?, #site_admin?, #site_admin_or_designer?, #site_staff?, #super_admin?

Constructor Details

This class inherits a constructor from Locomotive::ApplicationPolicy

Instance Method Details

#create?Boolean

Returns:



16
17
18
# File 'app/policies/locomotive/page_policy.rb', line 16

def create?
  site_staff? && !membership.visitor?
end

#destroy?Boolean

Returns:



24
25
26
# File 'app/policies/locomotive/page_policy.rb', line 24

def destroy?
  site_staff? && !@resource.index_or_not_found? && !membership.visitor?
end

#edit?Boolean

Returns:



12
13
14
# File 'app/policies/locomotive/page_policy.rb', line 12

def edit?
  site_staff?
end

#index?Boolean

Returns:



4
5
6
# File 'app/policies/locomotive/page_policy.rb', line 4

def index?
  site_staff?
end

#new?Boolean

Returns:



8
9
10
# File 'app/policies/locomotive/page_policy.rb', line 8

def new?
  site_staff?
end

#permitted_attributesObject



32
33
34
35
36
37
38
39
# File 'app/policies/locomotive/page_policy.rb', line 32

def permitted_attributes
  attributes = [:title, :layout_id, :slug, :parent_id, :listed, :published, :redirect, :redirect_url, :redirect_type, :seo_title, :meta_description, :meta_keywords]
  if site_admin_or_designer?
    attributes += [:cache_enabled, :cache_control, :cache_vary]
    attributes += [:handle]
  end
  attributes
end

#show?Boolean

Returns:



28
29
30
# File 'app/policies/locomotive/page_policy.rb', line 28

def show?
  site_admin_or_designer? || !@resource.hidden?
end

#update?Boolean

Returns:



20
21
22
# File 'app/policies/locomotive/page_policy.rb', line 20

def update?
  site_staff? && !membership.visitor?
end