diff --git a/CHANGELOG.md b/CHANGELOG.md index b5d2904..7096040 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,17 @@ ## Changelog +## v1.2.1 + +* Bug fixes + * Fix define structure via using + ## v1.2.0 * Enhancements * Add `struct` type ## v1.1.1 + * Enhancements * Definition in using macro * Add able to override fields diff --git a/lib/construct.ex b/lib/construct.ex index 18262bb..c7879f8 100644 --- a/lib/construct.ex +++ b/lib/construct.ex @@ -31,21 +31,21 @@ defmodule Construct do @doc false defmacro __using__(opts \\ []) do - definition = Keyword.get(opts, :do) + {definition, opts} = Keyword.pop(opts, :do) - structure = + pre_ast = if definition do defstructure(definition) else - [] + quote do + import Construct, only: [structure: 1] + end end quote do @behaviour Construct - import Construct, only: [structure: 1] - - unquote(structure) + unquote(pre_ast) @type t :: %__MODULE__{} diff --git a/mix.exs b/mix.exs index 191a35f..2fbef4b 100644 --- a/mix.exs +++ b/mix.exs @@ -3,7 +3,7 @@ defmodule Construct.Mixfile do def project do [app: :construct, - version: "1.2.0", + version: "1.2.1", elixir: "~> 1.3", deps: deps(), test_coverage: [tool: ExCoveralls],