DarkMatter.Modules (DarkMatter v1.1.4) View Source

Utils for working with modules.

Link to this section Summary

Functions

Determine if a given path is a beam file.

Turn a given path into its module.

Determine if a given module contains a defstruct definition.

Determine if a given module contains a defstruct definition.

Loads all accessible modules, and returns list of loaded modules

Loads all accessible modules, and returns list of loaded modules from a given dir.

Loads all accessible modules, and returns list of loaded modules

Determine keys for a given module or raises ArgumentError.

Link to this section Types

Link to this section Functions

Specs

beam_file?(path()) :: boolean()

Determine if a given path is a beam file.

Specs

beam_to_module(path()) :: module()

Turn a given path into its module.

Specs

defines_struct?(module()) :: boolean()

Determine if a given module contains a defstruct definition.

Examples

iex> defines_struct?(IO.Stream)
true

iex> defines_struct?(IO)
false

iex> defines_struct?(nil)
** (FunctionClauseError) no function clause matching in DarkMatter.Modules.defines_struct?/1

Specs

exports?(mfa()) :: boolean()

Determine if a given module contains a defstruct definition.

Examples

iex> exports?({Kernel, :+, 2})
true

iex> exports?({Kernel, :*, 0})
false

iex> exports?({Kernel, :/, -100})
** (FunctionClauseError) no function clause matching in DarkMatter.Modules.exports?/1

iex> exports?(nil)
** (FunctionClauseError) no function clause matching in DarkMatter.Modules.exports?/1

Specs

load_all() :: [path()]

Loads all accessible modules, and returns list of loaded modules

Specs

load_dir(path()) :: [path()]

Loads all accessible modules, and returns list of loaded modules from a given dir.

Specs

load_path(module(), path()) ::
  :ok
  | {:error, :badfile}
  | {:error, :nofile}
  | {:error, :not_purged}
  | {:error, :on_load_failure}
  | {:error, :sticky_directory}
  | {:error, {:module_mismatch, module()}}

Loads all accessible modules, and returns list of loaded modules

Specs

struct_keys!(module()) :: [atom()]

Determine keys for a given module or raises ArgumentError.

Examples

iex> struct_keys!(IO.Stream)
[:device, :line_or_bytes, :raw]

iex> struct_keys!(IO)
** (ArgumentError) Expected `defstruct` definition for: `IO`

iex> struct_keys!(nil)
** (FunctionClauseError) no function clause matching in DarkMatter.Modules.struct_keys!/1