magicGateResultEnricher function

String? magicGateResultEnricher(
  1. Element element,
  2. RefRegistry refs
)

Enricher: emits magicGateResult: <ability>.<allowed|denied> for the most recently cached GateResult in Gate.manager.

Reads the cache via Gate.manager.lastResult(...); the cache itself is populated transparently by every Gate.allows/denies call. Returns null when the cache is empty (no checks yet, or flush() was called).

Implementation

String? magicGateResultEnricher(Element element, RefRegistry refs) {
  final result = _mostRecentGateResult();
  if (result == null) return null;
  final outcome = result.allowed ? 'allowed' : 'denied';
  return 'magicGateResult: ${result.ability}.$outcome';
}