All modules have an intro.

This commit is contained in:
Felipe Sere
2016-05-11 21:44:18 +01:00
parent 94ab9826ae
commit f5477f0fb0
16 changed files with 30 additions and 12 deletions

View File

@@ -83,15 +83,12 @@ defmodule Koans do
defmacro __before_compile__(env) do
koans = koans(env)
intro = extract_into(env)
quote do
def all_koans do
unquote(koans)
end
def intro do
unquote(intro)
end
def intro, do: @intro
end
end
@@ -101,13 +98,6 @@ defmodule Koans do
|> Enum.reverse
end
defp extract_into(env) do
env.module
|> Module.get_attribute(:intro)
|> default("")
|> String.strip
end
defp default(nil, n), do: n
defp default(n, _), do: n
end