modelAttributeToSource function

String modelAttributeToSource(
  1. ModelAttribute attribute
)

Converts a model-level attribute back into schema source.

Implementation

String modelAttributeToSource(ModelAttribute attribute) {
  if (attribute.arguments.isEmpty) {
    return '@@${attribute.name}';
  }

  final arguments = attribute.arguments.entries
      .map((entry) {
        if (entry.key == 'value') {
          return entry.value;
        }
        return '${entry.key}: ${entry.value}';
      })
      .join(', ');
  return '@@${attribute.name}($arguments)';
}