Class: Locomotive::MembershipPolicy
Instance Attribute Summary
#membership, #resource
Instance Method Summary
collapse
#destroy_all?, #edit?, #initialize, #new?, #persisted?, #show?, #site_admin?, #site_admin_or_designer?, #site_staff?, #super_admin?
Instance Method Details
#change_role? ⇒ Boolean
The role cannot be set higher than the current one (we use the index in the roles array to check role presidence)
22
23
24
25
|
# File 'app/policies/locomotive/membership_policy.rb', line 22
def change_role?
roles = Locomotive::Membership::ROLES
roles.index(resource.role.to_s) <= roles.index(membership.role.to_s)
end
|
8
9
10
|
# File 'app/policies/locomotive/membership_policy.rb', line 8
def create?
site_admin_or_designer?
end
|
16
17
18
|
# File 'app/policies/locomotive/membership_policy.rb', line 16
def destroy?
site_admin_or_designer? && change_role?
end
|
4
5
6
|
# File 'app/policies/locomotive/membership_policy.rb', line 4
def index?
site_admin_or_designer?
end
|
#permitted_attributes ⇒ Object
27
28
29
|
# File 'app/policies/locomotive/membership_policy.rb', line 27
def permitted_attributes
[:email, :role]
end
|
12
13
14
|
# File 'app/policies/locomotive/membership_policy.rb', line 12
def update?
site_admin_or_designer? && change_role?
end
|