Packages

A simple way to describe dependencies that can be replaced at test time.

Retired package: Release invalid - Injecting was broken in this release

Current section

Files

Jump to
injex lib injex.ex
Raw

lib/injex.ex

defmodule Injex do
if Mix.env == :test do
defmacro inject(name, dep) do
quote do
def unquote(name)() do
Application.get_env(__MODULE__, unquote(name), unquote(dep))
end
end
end
else
defmacro inject(name, dep) do
quote do
def unquote(name)() do
unquote(dep)
end
end
end
end
end