Skip to content

Instantly share code, notes, and snippets.

View jakobdamjensen's full-sized avatar

Jakob Dam Jensen jakobdamjensen

View GitHub Profile
defmodule MyApp.Facade do
defmacro facade(mod) do
quote bind_quoted: [mod: mod] do
Enum.each apply(mod, :__info__, [:functions]), fn {fun, arity} ->
values = Enum.map(1..arity, &(Macro.var(:"arg#{&1}", mod)))
defdelegate unquote(fun)(unquote_splicing(values)), to: mod
end
end
end
end