Created
January 13, 2017 02:11
-
-
Save elbow-jason/60546a28257dff7efa79015c118f57fd 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 defines_function?(module, name, arity) do | |
defines_function?(module, name, arity) | |
end | |
def defines_function?(module, {name, arity}) do | |
try do | |
module.__info__(:functions) | |
|> Enum.member?({name, arity}) | |
rescue | |
UndefinedFunctionError -> | |
# this rescues the call to module.__info__(:functions) | |
false | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment