Created
March 19, 2019 21:20
-
-
Save lucasmazza/1a1fc04464a93316fbc5993b922bd3d9 to your computer and use it in GitHub Desktop.
This file contains 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
defmodule MyApp.Delegator do | |
defmacro __using__(opts) do | |
quote do | |
def unquote(:"$handle_undefined_function")(name, args) do | |
apply(Keyword.get(unquote(opts), :target), name, args) | |
end | |
end | |
end | |
end | |
defmodule MyApp.ACMECO do | |
def hello(), do: "hello" | |
def goodbye(), do: "goodbye" | |
end | |
defmodule MyApp.ACMECO.Staging do | |
use MyApp.Delegator, target: MyApp.ACMECO | |
def hello(), do: "HELLO YALL" | |
end | |
IO.inspect(MyApp.ACMECO.Staging.hello()) | |
IO.inspect(MyApp.ACMECO.Staging.goodbye()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment