ash/test/support/enum.ex

25 lines
610 B
Elixir

defmodule Status do
use Ash.Type.Enum, values: [:open, :Closed, :NeverHappened, :Always_Was]
def match("never_happened"), do: {:ok, :NeverHappened}
def match(value), do: super(value)
end
defmodule DescriptiveEnum do
use Ash.Type.Enum,
values: [
{:foo, "Clearly a foo"},
{:bar, "Obviously a bar"},
{:baz, "Undoubtedly a baz"},
:a_thing_with_no_description,
{:another_thing_with_no_description, nil}
]
end
defmodule StringEnum do
use Ash.Type.Enum, values: ["foo", "bar", "baz"]
end
defmodule MixedEnum do
use Ash.Type.Enum, values: [:foo, "bar", "baz"]
end