of static method

Access of(
  1. Object? azreq
)

Reads an AZREQ section; a missing or non-mapping section gives an access of kind '' that no role reaches.

Implementation

static Access of(Object? azreq) {
  if (azreq is! YamlMap) return Access('', const [], const [], '');
  final kind = field(azreq['content'], 'requirementKind');
  List<String> split(String text) => text
      .split(RegExp(r'[,\s]+'))
      .map((s) => s.trim())
      .where((s) => s.isNotEmpty)
      .toList();
  final keys = split(field(child(azreq, 'AZREQ-ENTL'), 'patterns'));
  final roles = split(field(child(azreq, 'AZREQ-ROLE'), 'roles'));
  final handler = field(child(azreq, 'AZREQ-CUST'), 'handler');
  return Access(kind, keys, roles, handler);
}