Created
July 2, 2018 07:11
-
-
Save thetamind/817be56b3cb17d0ad928eba5dcb12823 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 Bug.Default do | |
defmacro __using__(_) do | |
quote do | |
@impl Bug.Server | |
def one(), do: "Fallback" | |
def two(), do: "Fallback" | |
defoverridable Bug.Server | |
end | |
end | |
end | |
defmodule Bug.Server do | |
@callback one() :: String.t() | |
@callback two() :: String.t() | |
defmacro __using__(_) do | |
quote do | |
@behaviour unquote(__MODULE__) | |
use Bug.Default | |
end | |
end | |
end | |
defmodule Bug.Plugin do | |
defmacro __using__(_) do | |
quote do | |
@impl Bug.Server | |
def one() do | |
super() <> " + Plugin" | |
end | |
defoverridable Bug.Server | |
end | |
end | |
end | |
defmodule MyApp do | |
use Bug.Server | |
use Bug.Plugin | |
def one() do | |
super() <> " <- MyApp" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment