Enumex.Static.Components.Typespecs (Enumex v1.0.0)
View SourceA component that generates type specifications for enum definitions with static values.
This component automatically generates three types for each enum definition:
#{enum_name}_id
: represents the possible enum ids (atoms)#{enum_name}_index
: represents the possible enum indexes (non-negative integers)#{enum_name}_value
: represents the complete enum value structs
Example
defmodule MyApp.Enums do
use Enumex.Static, components: [Enumex.Static.Components.Typespecs]
# enum definitions go here
end
# generates types like:
@type my_enum_id() :: :first | :second | :third
@type my_enum_index() :: 1 | 2 | 3
@type my_enum_value() ::
Enumex.Value.t(MyApp.Enums, :my_enum, :first, 1)
| Enumex.Value.t(MyApp.Enums, :my_enum, :second, 2)
| Enumex.Value.t(MyApp.Enums, :my_enum, :third, 3)