View Source OnePiece.Commanded.Enum (OnePiece.Commanded v0.21.0)

Defines an Enum type module.

Summary

Functions

Converts the module into a struct with an :value enum field.

Functions

Link to this macro

__using__(opts)

View Source (macro)

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