# Dependency
Dependency injection for Elixir.
Dependency injection allows you to swap out dependencies when unit testing your modules.
In test mode a `Registry` is used that holds a mapping between dependency name and implementation.
In dev and production mode, the dependency is compiled inline - there is no perormance hit.
Inspired by [constantizer](https://github.com/aaronrenner/constantizer)
## Installation
The package can be installed by adding `dependency` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:dependency, "~> 0.1.0"}
]
end
```
Also, you'll need to add the application to your list of applications
```elixir
def application do
[
# ...
extra_applications: [:dependency],
]
end
```
## Usage
### Resolving a dependency
```elixir
import Dependency
mod = Dependency.resolve(MyModule)
```
### Registering an implementation
```elixir
Dependency.register(MyModule, MyImplementation)
```
## License
MIT