View Source Prototype (Prototype v0.8.0-alpha)

Documentation for Prototype.

Summary

Functions

Calls functions by searching up a prototype chain of modules, calling it on the first module where it is found.

Finds all matching functions up the prototype chain and returns them as a list.

Returns whether the given module exports the given function.

Returns the prototype module for a given module, if one exists.

Recursively builds a list of all modules in the prototype chain. Works for both modules and structs.

Functions

Link to this function

apply(target, name, args)

View Source
@spec apply(module() | struct(), atom(), list()) ::
  {:ok, atom(), map()} | {:missing_fun, atom(), list(), map()}

Calls functions by searching up a prototype chain of modules, calling it on the first module where it is found.

@spec call(list(), [{module(), atom(), integer()}]) :: any()
Link to this function

function_chain(target, name, arity)

View Source
@spec function_chain(module(), atom(), integer()) :: [function()]

Finds all matching functions up the prototype chain and returns them as a list.

(Note that a function of the correct arity may be exported by a module, but a FunctionClauseError would still be raised if there is not a matching function clause in that module. However, a matching clause may be found up further the prototype chain.)

Link to this function

has_function?(module, name, arity)

View Source
@spec has_function?(module(), atom(), integer()) :: boolean()

Returns whether the given module exports the given function.

@spec has_prototype?(module()) :: module() | false

Returns the prototype module for a given module, if one exists.

@spec prototype_chain(module() | struct()) :: [module()]

Recursively builds a list of all modules in the prototype chain. Works for both modules and structs.