PassiveSupport.Module (passive_support v0.8.4)
Convenience functions and helpers for module introspection
Link to this section Summary
Functions
For a module
and export
, returns either nil
or a tuple describing the export.
Retrieves an alias with the same name as string
if the alias was already referenced.
Link to this section Functions
Link to this function
check_for_export(module, export_type)
Specs
check_for_export(atom(), atom()) :: {:function | :macro, [non_neg_integer()]} | nil
For a module
and export
, returns either nil
or a tuple describing the export.
This function does not retrieve private function or macro arities, as its intended use case is for dynamically finding if a given function or macro can be called upon within a given module, and if so, with how many arguments.
## Examples
iex> check_for_export(String, :trim)
{:function, [1, 2]}
iex> check_for_export(PassiveSupport.Path.Sigil, :sigil_P)
{:macro, [2]}
iex> check_for_export(Integer, :possibly_private_but_equally_likely_not_to_exist)
nil
Link to this function
from_string(string)
Specs
Retrieves an alias with the same name as string
if the alias was already referenced.
Returns nil
if the alias has not already been referenced.
Examples
iex> from_string("PassiveSupport.Module")
PassiveSupport.Module
iex> from_string("PassiveSupport.Nodule")
nil