def verify_and_sort_permissions
      # DefaultPermissionSet is allowed to have blank permissions (private joinable), the other models need at least find and view
      self.permissions += [:find, :view] unless is_a?(DefaultPermissionSet)
    
      raise "Invalid permissions: #{(permissions - allowed_permissions).inspect}. Must be one of #{allowed_permissions.inspect}" unless permissions.all? {|permission| allowed_permissions.include? permission}
    
      self.permissions = permissions.uniq.sort_by { |permission| allowed_permissions.index(permission) }
    end
def verify_and_sort_permissions
      # DefaultPermissionSet is allowed to have blank permissions (private joinable), the other models need at least find and view
      self.permissions += [:find, :view] unless is_a?(DefaultPermissionSet)
    
      raise "Invalid permissions: #{(permissions - allowed_permissions).inspect}. Must be one of #{allowed_permissions.inspect}" unless permissions.all? {|permission| allowed_permissions.include? permission}
    
      self.permissions = permissions.uniq.sort_by { |permission| allowed_permissions.index(permission) }
    end
Verifies that all the access levels are valid for the attached permissible
 Makes sure no permissions are duplicated
 Enforces the order of access levels in the access attribute using the order of the permissions array