lifecycleComponentFilesMaker function

Iterable<PartFile> lifecycleComponentFilesMaker(
  1. ServerLifecycleComponent component,
  2. String formatter(
    1. Spec
    )
)

Implementation

Iterable<PartFile> lifecycleComponentFilesMaker(
  ServerLifecycleComponent component,
  String Function(Spec) formatter,
) sync* {
  List<String> path(String file) => [
        'lifecycle_components',
        component.name.toSnakeCase(),
        file.toNoCase().trim().toSnakeCase(),
      ];

  if (component.hasExceptionCatchers) {
    yield PartFile(
      path: path(component.exceptionClass.className),
      content: exceptionContent(component, formatter),
    );
  }

  if (component.hasGuards) {
    yield PartFile(
      path: path(component.guardClass.className),
      content: guardContent(component, formatter),
    );
  }

  if (component.hasMiddlewares) {
    yield PartFile(
      path: path(component.middlewareClass.className),
      content: middlewareContent(component, formatter),
    );
  }

  if (component.hasInterceptors) {
    yield PartFile(
      path: path(component.interceptorClass.className),
      content: interceptorContent(component, formatter),
    );
  }
}