Skip to content

Instantly share code, notes, and snippets.

@takuoka
Last active December 1, 2017 20:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takuoka/e2193cb54c0038625018 to your computer and use it in GitHub Desktop.
Save takuoka/e2193cb54c0038625018 to your computer and use it in GitHub Desktop.
Elixir の require, imoport, use ref: http://qiita.com/taku_oka/items/61178122e7bd52188af1
defmacro __using__(_opts) do
quote do
use Ecto.Schema
import Ecto.Changeset
import Ecto.Query, only: [from: 2]
import Ecto.Model
use Ecto.Model.OptimisticLock
use Ecto.Model.Timestamps
use Ecto.Model.Dependent
use Ecto.Model.Autogenerate
use Ecto.Model.Callbacks
end
end
require MyMacros
iex> import List
iex> flatten([1, [2], 3])
[1,2,3]
use HelloPhoenix.Web, :router
use ExUnit.Case, async: true
require ExUnit.Case
ExUnit.Case.__using__([async: true])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment