Skip to content

Instantly share code, notes, and snippets.

@Wigny
Created April 27, 2024 19:17
Show Gist options
  • Save Wigny/cdd8f631932fce9188cfa4cce1e0613e to your computer and use it in GitHub Desktop.
Save Wigny/cdd8f631932fce9188cfa4cce1e0613e to your computer and use it in GitHub Desktop.
defmacro delegate_functions_for(module, functions) do
for {fun_name, fun_arity} <- functions do
fun_args = Macro.generate_arguments(fun_arity, Macro.expand_literals(module, __CALLER__))
quote do
defdelegate unquote(fun_name)(unquote_splicing(fun_args)), to: unquote(module)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment