Class: MembershipPolicy
- Inherits:
-
ApplicationPolicy
- Object
- ApplicationPolicy
- MembershipPolicy
- Defined in:
- app/policies/membership_policy.rb
Overview
Protects Membership objects
Instance Method Summary collapse
-
#create? ⇒ false
(also: #new?)
Memberships can only be created via Invitation.
-
#destroy? ⇒ Boolean
If attempting to destroy one's own membership, or if the user is an admin and is not attempting to destroy another admin's membership.
-
#index? ⇒ Boolean
(also: #show?)
All users can view an organization's memberships.
- #update? ⇒ true, false (also: #edit?)
Methods inherited from ApplicationPolicy
Constructor Details
This class inherits a constructor from ApplicationPolicy
Instance Method Details
#create? ⇒ false Also known as: new?
Returns Memberships can only be created via Invitation
13 14 15 |
# File 'app/policies/membership_policy.rb', line 13 def create? false end |
#destroy? ⇒ Boolean
Returns if attempting to destroy one's own membership, or if the user is an admin and is not attempting to destroy another admin's membership
31 32 33 34 35 36 |
# File 'app/policies/membership_policy.rb', line 31 def destroy? return true if organization_user.staff? return true if self? return false if same_rank_or_lower? organization_user.admin? end |
#index? ⇒ Boolean Also known as: show?
Returns all users can view an organization's memberships
4 5 6 |
# File 'app/policies/membership_policy.rb', line 4 def index? true end |
#update? ⇒ true, false Also known as: edit?
21 22 23 24 25 26 |
# File 'app/policies/membership_policy.rb', line 21 def update? return true if organization_user.staff? return false if self? return false if same_rank_or_lower? organization_user.admin? end |