We are using enum_type in our CQRS event store (no Ecto) where structs are deserliazed from a JSON.
It would be useful to support casting from enum modules that were saved as strings in our event store, i.e. "Elixir.Modules."
We solved by adding something like this to each defenum:
Enum.each(@possible_options, fn {k, _} ->
def cast(unquote(to_string(k))), do: {:ok, unquote(k)}
end)
Thoughts?
We are using enum_type in our CQRS event store (no Ecto) where structs are deserliazed from a JSON.
It would be useful to support casting from enum modules that were saved as strings in our event store, i.e.
"Elixir.Modules."We solved by adding something like this to each
defenum:Thoughts?