createRecap static method

Map<String, dynamic> createRecap(
  1. String namespace,
  2. String ability,
  3. List<String> methods, {
  4. Map limits = const {},
})

Implementation

static Map<String, dynamic> createRecap(
  String namespace,
  String ability,
  List<String> methods, {
  Map limits = const {},
}) {
  try {
    final sortedMethods = List<String>.from(methods)
      ..sort((a, b) => a.compareTo(b));

    Map<String, dynamic> abilities = {};
    for (var method in sortedMethods) {
      abilities['$ability/$method'] = [
        ...(abilities['$ability/$method'] ?? []),
        limits,
      ];
    }

    return {
      'att': {
        namespace: Map<String, dynamic>.fromEntries(abilities.entries),
      }
    };
  } catch (e) {
    rethrow;
  }
}