grants function
Whether entitlements grant code: a flag that is on, a number that is not
zero, or a text that is not empty. Absent, off, zero or empty is not
granted. The code is matched exactly, case included.
Implementation
bool grants(Map<String, Entitlement>? entitlements, String code) => switch (entitlements?[code]) {
FlagEntitlement(:final value) => value,
NumberEntitlement(:final value) => value != 0,
TextEntitlement(:final value) => value.isNotEmpty,
null => false,
};