Sha256: 65276a5ae95832bef848460398fb89b508cc23ceb28a25ec4702d91c644642ee
Contents?: true
Size: 661 Bytes
Versions: 11
Compression:
Stored size: 661 Bytes
Contents
module Locomotive class MembershipPolicy < ApplicationPolicy def index? site_admin_or_designer? end def create? site_admin_or_designer? end def update? site_admin_or_designer? && change_role? end def destroy? site_admin_or_designer? && change_role? end # The role cannot be set higher than the current one (we use the index in # the roles array to check role presidence) def change_role? roles = Locomotive::Membership::ROLES roles.index(resource.role.to_s) <= roles.index(membership.role.to_s) end def permitted_attributes [:email, :role] end end end
Version data entries
11 entries across 11 versions & 1 rubygems