Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- defmodule Foo do
- defmacro import_sibling(name) do
- new_module = __MODULE__
- |> Module.split()
- |> List.delete_at(-1)
- |> List.insert_at(-1, unquote(name))
- |> Module.concat()
- quote do
- import unquote(new_module)
- end
- end
- end
- defmodule MyApp.Bar do
- import Foo
- import_sibbling(Baz)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement