Hello!
I am looking for a way to inspect generated code.
Given this module source:
defmodule Xyz do
@names [:a, :b, :c]
for name <- @names do
def hello(unquote(name)), do: "hello #{unquote(name)}"
end
end
How can I use the Code
/ Macro
/ other modules to produce the resulting module source code, like this?
defmodule Xyz do
@names [:a, :b, :c]
def hello(:a), do: "hello a"
def hello(:b), do: "hello b"
def hello(:c), do: "hello c"
end
Ideally the solution would also handle injection of code in modules at runtime as well.