From fa9b5b7309c48c063fbc7cc1bafae75ef4226094 Mon Sep 17 00:00:00 2001 From: balysv Date: Mon, 30 Dec 2024 10:06:15 +0100 Subject: [PATCH] Replace Module.eval_quoted with Code.eval_quoted --- lib/instream/connection.ex | 2 +- lib/instream/series.ex | 28 ++++++++++++++++++---------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/lib/instream/connection.ex b/lib/instream/connection.ex index 023f909..96ffe46 100644 --- a/lib/instream/connection.ex +++ b/lib/instream/connection.ex @@ -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 diff --git a/lib/instream/series.ex b/lib/instream/series.ex index 7c1391f..a7e0ffc 100644 --- a/lib/instream/series.ex +++ b/lib/instream/series.ex @@ -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 @@ -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 @@ -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)