Skip to content

Commit

Permalink
Fix for enforced keys
Browse files Browse the repository at this point in the history
  • Loading branch information
mruoss committed Apr 23, 2023
1 parent 366a4e6 commit 2617b87
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ymlr/encoder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ defimpl Ymlr.Encoder, for: Any do
quote do
defimpl Ymlr.Encoder, for: unquote(module) do
def encode(data, idnent_level, opts) do
defaults = @for |> struct!() |> Map.from_struct() |> MapSet.new()
defaults = @for |> struct() |> Map.from_struct() |> MapSet.new()

data
|> Map.from_struct()
Expand Down
1 change: 1 addition & 0 deletions test_support/structs.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ end

defmodule TestStructDerivedExceptDefaults do
@derive {Ymlr.Encoder, except: :defaults}
@enforce_keys [:foo]
defstruct [:foo, bar: 1, baz: :ok]
end

0 comments on commit 2617b87

Please sign in to comment.