-
Notifications
You must be signed in to change notification settings - Fork 38
Open
Description
I've noticed .Type is generated by Waffle.Ecto.Definition's macros as a submodule of our custom uploader Definition. If I want to extend the Ecto.Type so I can add forms in Kaffy admin, I can't figure out a clean way to extend the module that is created using this code:
defmodule Module.concat(unquote(definition), "Type") do
# After the 3.2 version Ecto has moved @behavior
# inside the `__using__` macro
if macro_exported?(Ecto.Type, :__using__, 1) do
use Ecto.Type
else
# in order to support versions lower than 3.2
@behaviour Ecto.Type
end
def type, do: Waffle.Ecto.Type.type()
def cast(value), do: Waffle.Ecto.Type.cast(unquote(definition), value)
def load(value), do: Waffle.Ecto.Type.load(unquote(definition), value)
def dump(value), do: Waffle.Ecto.Type.dump(unquote(definition), value)
endI'm also not too familiar with metaprogramming in elixir so maybe there's a trick to extend the generated .Type submodule to add the functions I want to add render_form/5 and render_index/3 to integrate a Waffle.Ecto type into Kaffy Admin.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels