Hi
I have an Application that keeps a behaviour definition for its interface (to improve testing of its clients by creating a test stub that implements the same interface). The behaviour looks like:
defmodule Register.DocEvents do
defmacro __using__(_) do
quote do
@behaviour Register.DocEvents
end
end
@callback initialize(soure :: atom()) :: :ok | {:error, String.t()}
...
end
I then implement the same behaviour for the Application like:
defmodule Register do
use Register.DocEvents
@impl Register.DocEvents
def initialize(source) do
Register.Server.initialize(Register.Server, source)
end
...
end
But I would like to do like this instead:
defmodule Register do
use Register.DocEvents
@impl Register.DocEvents
defdelegate initialize(source), to: Register.Server
...
end
It seems to work when I test, but I do not now if this could lead to any other negative effects?
Br Patrik