Last active
November 14, 2019 09:51
-
-
Save lorenzosinisi/2cdc713348e02413e1801221b6326ad7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def answer_types do | |
:code.all_loaded() | |
# turn everything into a string | |
|> Enum.map(&(elem(&1, 0) |> to_string)) | |
# take only the modules that are scoped under AnswerType | |
|> Enum.filter(&Regex.match?(~r/YourModuleName./, &1)) | |
# take the last element from the list (i.e ["ModuleParent", "Child"]) | |
|> Enum.map(&(String.split(&1, ".") |> Enum.take(-1))) | |
# there may be duplicates | |
|> Enum.uniq() | |
# there may be nested lists | |
|> List.flatten() | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you so much for this function!