SessionsConfig.fromYaml constructor

SessionsConfig.fromYaml(
  1. Object? node
)

Parses the sessions: map. Tolerant: never throws.

Implementation

factory SessionsConfig.fromYaml(Object? node) {
  if (node == null) return const SessionsConfig();
  if (node is! Map) {
    return const SessionsConfig(
      notes: ['sessions: not a map, defaults applied'],
    );
  }
  final notes = <String>[];
  var retention = const SessionRetentionConfig();
  node.forEach((key, value) {
    switch ('$key') {
      case 'retention':
        retention = SessionRetentionConfig.fromYaml(value);
      default:
        notes.add('sessions.$key: unknown key (ignored)');
    }
  });
  return SessionsConfig(
    retention: retention,
    notes: List.unmodifiable(notes),
  );
}