Class: Locomotive::ApplicationPolicy
- Inherits:
-
Object
- Object
- Locomotive::ApplicationPolicy
show all
- Defined in:
- app/policies/locomotive/application_policy.rb
Direct Known Subclasses
AccountPolicy, ContentAssetPolicy, ContentEntryPolicy, ContentTypePolicy, MembershipPolicy, PagePolicy, SectionPolicy, SitePolicy, SnippetPolicy, ThemeAssetPolicy, TranslationPolicy
Defined Under Namespace
Classes: Scope
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(membership, resource) ⇒ ApplicationPolicy
The resource is always scoped by the site defined by the membership.
20
21
22
23
24
25
26
|
# File 'app/policies/locomotive/application_policy.rb', line 20
def initialize(membership, resource)
@membership = membership
@resource = resource
raise Pundit::NotAuthorizedError, 'must be logged in' unless account
raise Pundit::NotAuthorizedError, 'should have a resource' unless resource
end
|
Instance Attribute Details
#membership ⇒ Object
Returns the value of attribute membership.
17
18
19
|
# File 'app/policies/locomotive/application_policy.rb', line 17
def membership
@membership
end
|
#resource ⇒ Object
Returns the value of attribute resource.
17
18
19
|
# File 'app/policies/locomotive/application_policy.rb', line 17
def resource
@resource
end
|
Instance Method Details
48
49
50
|
# File 'app/policies/locomotive/application_policy.rb', line 48
def create?
false
end
|
52
53
54
|
# File 'app/policies/locomotive/application_policy.rb', line 52
def destroy?
false
end
|
#destroy_all? ⇒ Boolean
56
57
58
|
# File 'app/policies/locomotive/application_policy.rb', line 56
def destroy_all?
false
end
|
36
37
38
|
# File 'app/policies/locomotive/application_policy.rb', line 36
def edit?
update?
end
|
28
29
30
|
# File 'app/policies/locomotive/application_policy.rb', line 28
def index?
false
end
|
44
45
46
|
# File 'app/policies/locomotive/application_policy.rb', line 44
def new?
create?
end
|
76
77
78
|
# File 'app/policies/locomotive/application_policy.rb', line 76
def persisted?
resource.try(:persisted?)
end
|
32
33
34
|
# File 'app/policies/locomotive/application_policy.rb', line 32
def show?
index?
end
|
#site_admin? ⇒ Boolean
72
73
74
|
# File 'app/policies/locomotive/application_policy.rb', line 72
def site_admin?
membership.admin?
end
|
#site_admin_or_designer? ⇒ Boolean
68
69
70
|
# File 'app/policies/locomotive/application_policy.rb', line 68
def site_admin_or_designer?
membership.admin? || membership.designer?
end
|
#site_staff? ⇒ Boolean
60
61
62
|
# File 'app/policies/locomotive/application_policy.rb', line 60
def site_staff?
membership.site.present?
end
|
#super_admin? ⇒ Boolean
64
65
66
|
# File 'app/policies/locomotive/application_policy.rb', line 64
def super_admin?
account.super_admin?
end
|
40
41
42
|
# File 'app/policies/locomotive/application_policy.rb', line 40
def update?
false
end
|