Created
February 13, 2015 13:46
-
-
Save os6sense/db80d6970db6091f9089 to your computer and use it in GitHub Desktop.
__using__ using use
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# used from within a test (e.g. use UseDI.A) the following is output: | |
# __using__ UseDI. caller : Elixir.UseDependencyInjectionTest | |
# __using__ UseDI.A. caller : Elixir.UseDependencyInjectionTest | |
import IO, only: [puts: 1] | |
defmodule UseDI do | |
defmacro __using__(_) do | |
quote do | |
puts " __using__ UseDI. caller : #{unquote(__CALLER__.module)}" | |
end | |
end | |
end | |
defmodule UseDI.A do | |
defmacro __using__(_) do | |
quote do | |
use UseDI | |
puts " __using__ UseDI.A. caller : #{unquote(__CALLER__.module)}" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment