Skip to content

Instantly share code, notes, and snippets.

@pfac
Created March 17, 2015 17:41
Show Gist options
  • Save pfac/ba79941219c445113c18 to your computer and use it in GitHub Desktop.
Save pfac/ba79941219c445113c18 to your computer and use it in GitHub Desktop.
Recursive macros failed attempt
defmodule Ninja.Macros do
defmacro __using__ [{ :name, value } | options] do
{:__block__, [], [
quote do
@name unquote value
def name, do: @name
end,
__MODULE__.__using__(options)
]
}
end
defmacro __using__ _ do
end
end
defmodule Ninja.Macros.Fixture do
use Ninja.Macros, name: "test"
end
defmodule Ninja.Macros.Test do
use ExUnit.Case
alias Ninja.Macros.Fixture
test "#name returns the correct value" do
assert Fixture.name == "test"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment