Skip to content

Support casting from module as string ("Elixir.") #13

Description

@fabriziosestito

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions