As the title states, my question is:
Is there a way to determine a module exists by its name in Elixir?
After looking around for some time I came around this thread in the Elixir forums but is not exactly what I'm looking for. In this thread they mention Code.ensure_loaded/1
, but I don't think it is quite what I need.
Right now I'm approaching the problem with something as follows:
def module_exists?(module_name) where is_atom(module_name) do
!is_nil(module_name.module_info)
rescue
e in UndefinedFunctionError -> false
end
But I'm not convinced.
Any help is appreciated, thanks!