Dependency v0.1.0 Dependency View Source

Fuctions to build soft dependencies between modules. This is useful when you want to test with diffirent situations in test mode.

The resolution is dynamic in test mode (uses Registry). In dev and production modes, the dependency in compiled inline.

Link to this section Summary

Functions

Register an implementation for a module

Resolve the implementation for a module

Starts the dependency registry

Link to this section Functions

Link to this function register(mod, implementation) View Source
register(module(), module()) :: {:ok, module()}

Register an implementation for a module.

Returns {:ok, module}

Examples

iex> Dependency.register(Foo, Bar)

Link to this macro resolve(name) View Source (macro)
resolve(module()) :: module()

Resolve the implementation for a module.

Returns module

Examples

iex> Dependency.register(Foo, Bar)

iex> Dependency.resolve(Foo) Bar

Link to this function start_link() View Source
start_link() :: {:ok, pid()} | {:error, atom()}

Starts the dependency registry.

This is done for you if you add :dependency to list of apps in your mix.exs.

Returns {:ok, pid}