Skip to content

Commit b65a592

Browse files
committed
Simplify dynamic method generation
The Elixir side can be written using normal unquoting.
1 parent 3c6fe53 commit b65a592

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

lib/desktop/wx.ex

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,9 @@ defmodule Desktop.Wx do
2424
"""
2525
)
2626

27-
for wx_constant <- @constants do
28-
Module.eval_quoted(
29-
__MODULE__,
30-
Code.string_to_quoted("""
31-
def wx#{wx_constant}, do: :desktop_wx.get(:wx#{wx_constant})
32-
""")
33-
)
34-
end
27+
@constants
28+
|> Enum.map(&String.to_atom("wx" <> &1))
29+
|> Enum.each(fn prefixed_constant ->
30+
def unquote(prefixed_constant)(), do: :desktop_wx.get(unquote(prefixed_constant))
31+
end)
3532
end

0 commit comments

Comments
 (0)