Class: Locomotive::SitePolicy

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

Defined Under Namespace

Classes: Scope

Instance Attribute Summary

Attributes inherited from ApplicationPolicy

#membership, #resource

Instance Method Summary collapse

Methods inherited from ApplicationPolicy

#destroy_all?, #initialize, #new?, #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:


32
33
34
# File 'app/policies/locomotive/site_policy.rb', line 32

def create?
  !.visitor?
end

#destroy?Boolean

Returns:


40
41
42
# File 'app/policies/locomotive/site_policy.rb', line 40

def destroy?
  super_admin? || site_admin?
end

#edit?Boolean

Returns:


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

def edit?
  super_admin? || site_staff?
end

#index?Boolean

Returns:


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

def index?
  true
end

#newObject


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

def new
  !.visitor?
end

#permitted_attributesObject


56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'app/policies/locomotive/site_policy.rb', line 56

def permitted_attributes
  plain = [
    :name, :handle, :picture, :remove_picture, :seo_title, :meta_keywords, :meta_description, :robots_txt,
    :timezone_name, :timezone,
    :cache_enabled, :cache_control, :cache_vary,
    :asset_host, :redirect_to_first_domain, :redirect_to_https,
    :private_access, :password, :prefix_default_locale, :bypass_browser_locale
  ]
  hash  = { domains: [], locales: [], url_redirections: [] }

  if persisted? && !update_advanced?
    plain -= [:timezone_name, :timezone, :robots_txt, :cache_enabled, :cache_control, :cache_vary, :prefix_default_locale, :bypass_browser_locale, :asset_host]
    hash.delete(:locales)
    hash.delete(:url_redirections)
  end

  unless point?
    plain -= [:handle, :redirect_to_first_domain, :redirect_to_https, :private_access, :password]
    hash.delete(:domains)
  end

  plain << hash
end

#point?Boolean

Returns:


44
45
46
# File 'app/policies/locomotive/site_policy.rb', line 44

def point?
  !persisted? || super_admin? || site_admin?
end

#show?Boolean

Returns:


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

def show?
  true
end

#show_developers_documentation?Boolean

Returns:


52
53
54
# File 'app/policies/locomotive/site_policy.rb', line 52

def show_developers_documentation?
  super_admin? || site_admin?
end

#update?Boolean

Returns:


36
37
38
# File 'app/policies/locomotive/site_policy.rb', line 36

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

#update_advanced?Boolean

Returns:


48
49
50
# File 'app/policies/locomotive/site_policy.rb', line 48

def update_advanced?
  super_admin? || site_admin?
end