datafoodconsortium / connector-codegen

An Acceleo project to generate the source code of the DFC connector into all the supported programming languages.
MIT License
3 stars 3 forks source link

[Ruby] Use nil as default value for all types #14

Closed mkllnk closed 4 months ago

mkllnk commented 7 months ago

The constructors were setting an empty string or the number zero depending on the type of the attribute. This made it impossible to tell if the value was actively set to zero or if it was not set at all.

Now it's possible to omit the stockLimitation attribute for unlimited stock.

This change also reduces the JSON file size by omitting these values.

lecoqlibre commented 7 months ago

@mkllnk The import feature has been merged and this should be tested with it, right?

mkllnk commented 7 months ago

The import feature has been merged and this should be tested with it, right?

Right. I tested and found that setting arrays to nil broke an assumption of the importer. So I'm keeping the empty array for now.

It would be even better if the importer knew if a property is a collection instead of checking for an array value. But for now this is good enough and we can improve it when we have a use case for it.

This has been rebased on the main branch.

mkllnk commented 5 months ago

@lecoqlibre This has been waiting for two months now. Is there any concern over merging this?