PermissionHandler.static constructor

PermissionHandler.static({
  1. bool? read,
  2. bool? update,
  3. bool? delete,
  4. bool? create,
  5. bool? write,
  6. required bool defaultPermission,
})

Implementation

PermissionHandler.static({
  bool? read,
  bool? update,
  bool? delete,
  bool? create,
  bool? write,
  required bool defaultPermission,
})  : beforeNeed = false,
      assert(write == null ||
          (update == null && delete == null && create == null)) {
  var defaultsMap = {
    if (write != null) DbOperationType.create: write,
    if (write != null) DbOperationType.update: write,
    if (write != null) 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[_.type] ?? defaultPermission;
  };
}