View Source Exrpc.MFA (exrpc v0.3.6)

This module provides functions to validate and create {module, function, arity} tuple.

Summary

Functions

Checks if the given {module, function, arity} or &module.function/arity is callable.

Returns list of mfa tuples from the given module.

Creates {module, function, arity} tuple from the given &module.function/arity or {module, function, arity}.

Checks if the given {module, function, arity} or &module.function/arity is valid.

Functions

@spec callable?(mfa() | (... -> any())) :: boolean()

Checks if the given {module, function, arity} or &module.function/arity is callable.

Examples

iex> Exrpc.MFA.callable?({Enum, :into, 2})
true
iex> Exrpc.MFA.callable?(&Enum.into/2)
true
iex> Exrpc.MFA.callable?(&Enum.into/255)
false
iex> Exrpc.MFA.callable?(&Enum.get_rich_quick/1)
false
@spec list(module()) :: [mfa()]

Returns list of mfa tuples from the given module.

Examples

iex> defmodule Foo do
iex>   def bar(), do: :ok
iex>   def baz(), do: qux()
iex>   defp qux(), do: :ok
iex> end
iex> Exrpc.MFA.list(Foo)
[{Foo, :bar, 0}, {Foo, :baz, 0}]
iex> Exrpc.MFA.list(NotAModule)
[]
@spec tuple(mfa() | (... -> any())) :: mfa()

Creates {module, function, arity} tuple from the given &module.function/arity or {module, function, arity}.

Examples

iex> Exrpc.MFA.tuple({Enum, :into, 2})
{Enum, :into, 2}
iex> Exrpc.MFA.tuple(&Enum.into/2)
{Enum, :into, 2}
@spec valid?(mfa() | (... -> any())) :: boolean()

Checks if the given {module, function, arity} or &module.function/arity is valid.

Examples

iex> Exrpc.MFA.valid?({Enum, :into, 2})
true
iex> Exrpc.MFA.valid?(&Enum.into/2)
true
iex> Exrpc.MFA.valid?(&Enum.into/255)
true
iex> Exrpc.MFA.valid?(&Enum.get_rich_quick/1)
true
iex> Exrpc.MFA.valid?(Enum)
false