View Source OnePiece.Commanded.Enum (OnePiece.Commanded v0.25.1)
Defines an Enum type module.
Summary
Functions
Converts the module into a struct with an :value
enum field.
Functions
Converts the module into a struct with an :value
enum field.
Using
Derives
Usage
defmodule BankAccountType do
use OnePiece.Commanded.Enum, values: [:business, :personal]
end
{:ok, type} = BankAccountType.new(:business)
You can use it in your Ecto.Schema
like this:
defmodule BankAccount do
use Ecto.Schema
embedded_schema do
field :type, BankAccountType
end
end