Skip to content

Commit

Permalink
Clean up a little
Browse files Browse the repository at this point in the history
  • Loading branch information
MegaRedHand committed Jan 16, 2024
1 parent 8f84c42 commit f4ad826
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
11 changes: 7 additions & 4 deletions lib/chain_spec/configs/gen_config.ex
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
defmodule ChainSpec.GenConfig do
@moduledoc """
Config behaviour, for auto-implementing configs.
Generic config behaviour, for auto-implementing configs.
"""

defmacro __using__(opts) do
file = Keyword.fetch!(opts, :file)
preset = Keyword.fetch!(opts, :preset)

quote do
@external_resource unquote(file)
@__parsed_config ConfigUtils.load_config_from_file!(unquote(file))
@__unified Map.merge(unquote(preset).get_preset(), @__parsed_config)
file = unquote(file)
preset = unquote(preset)

@external_resource file
@__parsed_config ConfigUtils.load_config_from_file!(file)
@__unified Map.merge(preset.get_preset(), @__parsed_config)

@behaviour unquote(__MODULE__)

Expand Down
6 changes: 4 additions & 2 deletions lib/chain_spec/presets/gen_preset.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ defmodule ChainSpec.GenPreset do
file = Keyword.fetch!(opts, :file)

quote do
@external_resource unquote(file)
file = unquote(file)

@__parsed_preset ConfigUtils.load_preset_from_dir!(unquote(file))
@external_resource file

@__parsed_preset ConfigUtils.load_preset_from_dir!(file)

@behaviour unquote(__MODULE__)

Expand Down

0 comments on commit f4ad826

Please sign in to comment.