Created
September 24, 2020 18:41
-
-
Save Dkendal/47c64400735976b60b405f6b84bae04c to your computer and use it in GitHub Desktop.
more elixir metaprogramming
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 Core.Github do | |
@behaviour Core.Github.Adapter | |
for {fun, arity} <- Core.Github.Adapter.behaviour_info(:callbacks) do | |
args = Macro.generate_arguments(arity, __MODULE__) | |
@impl true | |
def unquote(fun)(unquote_splicing(args)) do | |
apply(adapter(), unquote(fun), unquote(args)) | |
end | |
end | |
def adapter() do | |
Application.fetch_env!(:core, [Core.Github, :api_adapter]) | |
end | |
@doc """ | |
Creates a new client with the app token. | |
## Examples | |
iex> {:app, %{}} = app_client() | |
""" | |
def app_client(), do: adapter().app_client(Core.Github.JwtToken.generate_and_sign!()) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment