Closed zph closed 4 months ago
Note: this works for some cases but not inside matches and in function heads. To make these work cleanly it needs to be a defmacro and be inlined during compilation.
We can hold off on merging this until I can implement that component.
The conversion to Macros broke tests, revising :) and will comment when ready for review.
This is ready for review and I'm using it currently as it is in my own projects :).
This would be really helpful to ensure that we're using the right values as constants in the rest of the code-base (i.e. when creating records). Can this be merged? Although it could use some docs.
Are there any plans to merge this PR?
Implements https://github.com/gjaldon/ecto_enum/issues/87
This patch allows using enum variants as you would use a constant in some languages or a full featured Enum in others.
When variants are defined on an enum, a matching function will be defined for reducing code re-definitions.
It allows for usage as:
Complex atom types are also coerced into idiomatic names:
This PR works for both arity 2 and 3 versions of
defenum
. I had tested it for different cases in PG but have not deeply assessed any changes needed for MySQL.You're welcome to tweak the PR for small changes and I'm happy to adjust it myself if something more thorough is needed.
:D