PermissionHandler.generatedByType constructor
PermissionHandler.generatedByType({
- PermissionCheckerCallback? read,
- PermissionCheckerCallback? update,
- PermissionCheckerCallback? delete,
- PermissionCheckerCallback? create,
- PermissionCheckerCallback? write,
- required bool defaultPermission,
- bool beforeNeed = false,
Implementation
PermissionHandler.generatedByType(
{PermissionCheckerCallback? read,
PermissionCheckerCallback? update,
PermissionCheckerCallback? delete,
PermissionCheckerCallback? create,
PermissionCheckerCallback? write,
required bool defaultPermission,
this.beforeNeed = false})
: assert(write == null ||
(update == null && delete == null && create == null)) {
var defaultsMap = {
if (write != null) ...{
DbOperationType.create: write,
DbOperationType.update: write,
DbOperationType.delete: write,
},
if (read != null) DbOperationType.read: read,
if (update != null) DbOperationType.update: update,
if (create != null) DbOperationType.create: create,
if (delete != null) DbOperationType.delete: delete
};
checker = (_) {
return (defaultsMap[_.access.type]?.call(_)) ?? defaultPermission;
};
;
}