How could I enforce all keys in a struct without need to duplicate all the keys? To clarify, I'd like to DRY this:
defmodule Ticket do
@enforce_keys [:origin, :destination, :price]
defstruct [:origin, :destination, :price]
end
I can use additional variable:
defmodule Ticket do
struct_keys = [:origin, :destination, :price]
@enforce_keys struct_keys
defstruct struct_keys
end
It works properly, but looks noisy. Is there any better approach?