Use Ecto.Type instead of `@behaviour Ecto.Type`
This commit is contained in:
parent
3f1fc77d85
commit
8106093229
|
|
@ -79,8 +79,6 @@ for module <- ~w(ISBN ISMN ISSN ISBN13 ISMN13 ISSN13 UPC EAN13) do
|
||||||
ecto_type = module |> String.downcase() |> String.to_atom()
|
ecto_type = module |> String.downcase() |> String.to_atom()
|
||||||
|
|
||||||
defmodule module_name do
|
defmodule module_name do
|
||||||
@behaviour Ecto.Type
|
|
||||||
|
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Definition for the ISN.#{module} module.
|
Definition for the ISN.#{module} module.
|
||||||
|
|
||||||
|
|
@ -96,6 +94,8 @@ for module <- ~w(ISBN ISMN ISSN ISBN13 ISMN13 ISSN13 UPC EAN13) do
|
||||||
end
|
end
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
use Ecto.Type
|
||||||
|
|
||||||
def type, do: unquote(ecto_type)
|
def type, do: unquote(ecto_type)
|
||||||
|
|
||||||
def cast(nil), do: :error
|
def cast(nil), do: :error
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue