Skip to content

Commit

Permalink
Replace Module.eval_quoted with Code.eval_quoted
Browse files Browse the repository at this point in the history
  • Loading branch information
balysv committed Dec 30, 2024
1 parent 1557c77 commit fa9b5b7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/instream/connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ defmodule Instream.Connection do
}

defmacro __using__(opts) do
quote bind_quoted: [opts: opts], location: :keep do
quote bind_quoted: [opts: opts], location: :keep, generated: true do
alias Instream.Connection
alias Instream.Connection.Config
alias Instream.Connection.QueryRunnerV1
Expand Down
28 changes: 18 additions & 10 deletions lib/instream/series.ex
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ defmodule Instream.Series do
alias Instream.Series.Validator

defmacro __using__(opts) do
quote location: :keep do
quote location: :keep, generated: true do
unless unquote(opts[:skip_validation]) do
@after_compile unquote(__MODULE__)
end
Expand All @@ -175,7 +175,7 @@ defmodule Instream.Series do
Defines the series.
"""
defmacro series(do: block) do
quote location: :keep do
quote location: :keep, generated: true do
@behaviour unquote(__MODULE__)

@measurement nil
Expand All @@ -199,14 +199,22 @@ defmodule Instream.Series do
def __meta__(:measurement), do: @measurement
def __meta__(:tags), do: Keyword.keys(@tags_struct)

Module.eval_quoted(__ENV__, [
unquote(__MODULE__).__struct_fields__(@fields_struct),
unquote(__MODULE__).__struct_tags__(@tags_struct)
])

Module.eval_quoted(__ENV__, [
unquote(__MODULE__).__struct__(__MODULE__)
])
Code.eval_quoted(
[
unquote(__MODULE__).__struct_fields__(@fields_struct),
unquote(__MODULE__).__struct_tags__(@tags_struct)
],
[],
__ENV__
)

Code.eval_quoted(
[
unquote(__MODULE__).__struct__(__MODULE__)
],
[],
__ENV__
)

@impl unquote(__MODULE__)
def from_map(data), do: Hydrator.from_map(__MODULE__, data)
Expand Down

0 comments on commit fa9b5b7

Please sign in to comment.