Enumex.Static.Components.List behaviour (Enumex v1.0.0)
View SourceA component that provides functionality for listing enum values in a few formats.
Example
defmodule MyApp.Enums do
use Enumex.Static, components: [Enumex.Static.Components.List]
end
Summary
Callbacks
Returns a list of enum values in the specified format.
Callbacks
@callback list(Enumex.Value.enum_name(), type :: :ids) :: [Enumex.Value.id()]
@callback list(Enumex.Value.enum_name(), type :: :indexes) :: [Enumex.Value.index()]
@callback list(Enumex.Value.enum_name(), type :: :values) :: [Enumex.Value.t()]
Returns a list of enum values in the specified format.
Examples
iex> MyApp.Enums.list(:my_enum, :ids)
~w[first second third]a
iex> MyApp.Enums.list(:my_enum, :indexes)
[1, 2, 3]
iex> MyApp.Enums.list(:my_enum, :values)
[
Value.new(MyApp.Enums, :my_enum, :first, 1),
Value.new(MyApp.Enums, :my_enum, :second, 2),
Value.new(MyApp.Enums, :my_enum, :third, 3)
]