Hi, I have a “base” module with this
defmodule DbModel do
@callback schema() :: Map.t
defmacro __using__(_opts) do
quote do
@behaviour DbModel
...boiler plates with actual implementation...
def schema(), do: %{}
defoverridable schema: 0
end
end
...stuffs implemented for this base module...
end
Then I have a module
defmodule CustomerM do
defstruct id: nil,
...other props...
use ExConstructor
@impl DbModel
def schema(), do: %{
...specific schema validation and conversion...
}
use DbModel
end
It works well for my application, but one thing bugs me is this:
warning: this clause cannot match because a previous clause at line xx always matches
lib/db/model/customer_m.ex:31
Yes, I know about Ecto etc, but I choose this way of handling db model for a reason.
My question is more general: What is the correct way to achieve this kind of function overriding?
Thanks a lot!