evaluate method

Future<PatchbayGateRejection?> evaluate(
  1. Iterable<String> gateIds
)

Implementation

Future<PatchbayGateRejection?> evaluate(Iterable<String> gateIds) async {
  final PatchbayGateAdmissionScope? scope = patchbayGateAdmissionScope;
  if (!(scope?.skipBase ?? false)) {
    final PatchbayGateDecision base = await _baseGate();
    if (!base.allowed) {
      scope?.reportGateResult('rejected');
      return PatchbayGateRejection(
        gateId: 'patchbay.base',
        code: base.code ?? 'baseGateRejected',
        notice: base.notice,
      );
    }
  }

  final List<String> ordered =
      gateIds
          .where(
            (String gateId) =>
                !(scope?.admittedGateIds.contains(gateId) ?? false),
          )
          .toSet()
          .toList()
        ..sort();
  if (ordered.isNotEmpty) scope?.enterOperationPolicy();
  for (final String gateId in ordered) {
    final PatchbayGateDecision decision = await _consumerGate(gateId);
    if (!decision.allowed) {
      scope?.reportGateResult('rejected');
      return PatchbayGateRejection(
        gateId: gateId,
        code: decision.code ?? 'consumerGateRejected',
        notice: decision.notice,
      );
    }
  }
  if (ordered.isNotEmpty) scope?.reportGateResult('passed');
  return null;
}