View Source JetExt.Ecto.Enum (jet_ext v0.1.0)
Defining an Enum Ecto type.
Parameterized Type
iex> type = Ecto.ParameterizedType.init(JetExt.Ecto.Enum, values: [:foo, :bar])
{
:parameterized,
JetExt.Ecto.Enum,
%{
mappings: [foo: "foo", bar: "bar"],
on_cast: %{"FOO" => :foo, "BAR" => :bar, "foo" => :foo, "bar" => :bar},
on_dump: %{foo: "FOO", bar: "BAR"},
on_load: %{"FOO" => :foo, "BAR" => :bar},
type: :string
}
}
Type Module
defmodule EnumType do
use JetExt.Ecto.Enum, [:foo, :bar, :baz]
end
# cast iex> EnumType.cast("foo")
iex> EnumType.cast("FOO")
iex> EnumType.cast(:foo)
# load iex> EnumType.load("foo")
iex> EnumType.load("FOO")
# dump iex> EnumType.dump(:foo)
Summary
Functions
Returns the possible dump values for a given schema and field
Returns the mappings for a given schema and field
Returns the possible values for a given schema and field
Types
@type t() :: atom()
Functions
Returns the possible dump values for a given schema and field
Returns the mappings for a given schema and field
Returns the possible values for a given schema and field