Macro-noob question… Can anyone tell me what I’m doing wrong to get this code to evaluate - I’m looking to write something that will generate a load of module aliases for an .iex.exs file.
I’ve got the following code which generates a list of FooCompany Ecto schemas :
:code.all_loaded |> Enum.map(&(Atom.to_string(elem(&1,0)))) |> Enum.filter(&Regex.match?(~r"Elixir.FooCompany.Schemas",&1))
What I’d like to do with these schemas is automatically genenerate alias statements which will be available to iex via the magic of the .iex.exs file:
I’ve been messing around with stuff like this, but can’t get it to eval the quoted block, I’d like to put an Enum.map and automagically generate all the aliases (350 and counting)
Code.eval_quoted( quote bind_quoted: [name: TheScoreData.Schemas.GolfPlayer], unquote: true do alias unquote(name) end )