I have a metaprogramming question.
I have some modules in my code base (of course). Some are normal camel case modules (e.g. Abc.Def.Ghi) and some have all caps (e.g. Jkl.Mno.PQR). I want to construct the module names dynamically from snake case strings. This can be done fine with Macro.camelize/1
for the normal camel case modules, but the all caps parts mess this up. To overcome this I was wondering if there is a way to dynamically lookup the available modules so I can find the match ignoring case and use that. Does anyone know if this is possible?
I was hoping Module.__info__/1
would accept a :modules
atom to get its sub-modules but that isn’t an option, which makes sense.
Another thought I had was if perhaps I can somehow register these details during module compilation by hooking into the compilation system.
Any help is appreciated. Thanks.