ectonum v1.0.0 Ectonum
Adds a defenum/2
macro for defining enum types for Ecto schemas.
Summary
Functions
Defines a custom Ecto.Type
for enumerated fields.
Usage
defmodule Profile do
import Ectonum
defenum GenderEnum, [:male, :female]
schema "profiles" do
field :gender, GenderEnum
end
end
In the above example the :gender
field will cast both string and atom values matching any of the options specified in the enum type.