-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
It would be nice to have a way to set default plugins for derived variations. I’m trying to make a typedstruct
wrapper that also implements Ecto.Type
. Something like:
defmodule MyApp.Type do
defmacro __using__(_) do
quote do
use Ecto.Type
use Typedstruct
# use TypedStruct, plugins: [MyApp.Typestruct.Plugin.EctoTypes]
@behaviour MyApp.Type
@impl Ecto.Type
def type, do: :map
# …
end
end
@callback changeset(struct, map) :: Ecto.Changeset.t()
end
Right now, I would need to do:
typedstruct do
plugin MyApp.Typestruct.Plugin.EctoTypes
field :code, String.t(), ecto_type: :string
end
With this, I would be able to do:
typedestruct do
field :code, String.t(), ecto_type: :string
end
I could probably muck around with the block AST by overriding typedstruct/1,2
, and I’ll be trying that, but it feels like specifying default plugins for a project like this would be a desirable feature overall.
Metadata
Metadata
Assignees
Labels
No labels