Last active
September 5, 2015 09:09
-
-
Save amencarini/ed2c148eab0edc9f21d5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Client do | |
defmacro __using__(resources: resources) do | |
for {singlular, plural} <- resources do | |
quote bind_quoted: [singlular: singlular, plural: plural] do | |
def one(singlular, id) do | |
get("/api/#{plural}/#{id}") | |
end | |
end | |
end | |
end | |
def get(url) do | |
IO.puts inspect(url) | |
end | |
end | |
defmodule AppCode do | |
use Client, resources: [{:product, :products}, {:category, :categories}] | |
def test, do: Client.one(:product, 12) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment