Skip to content

Instantly share code, notes, and snippets.

@elbow-jason
Created January 13, 2017 02:11
Show Gist options
  • Save elbow-jason/60546a28257dff7efa79015c118f57fd to your computer and use it in GitHub Desktop.
Save elbow-jason/60546a28257dff7efa79015c118f57fd to your computer and use it in GitHub Desktop.
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