Skip to content

Instantly share code, notes, and snippets.

@ihumanable
Created November 23, 2021 00:36
Show Gist options
  • Save ihumanable/f3c42379c70c05cf1cebdcbf30e5a9c1 to your computer and use it in GitHub Desktop.
Save ihumanable/f3c42379c70c05cf1cebdcbf30e5a9c1 to your computer and use it in GitHub Desktop.
Patch.Mock.Server delegate/3 simplified
def delegate(module, name, arguments) do
server = Naming.server(module)
case GenServer.call(server, {:delegate, name, arguments}) do
{:ok, reply} ->
reply
:error ->
original = Naming.original(module)
apply(original, name, arguments)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment