stavro / arc_ecto

An integration with Arc and Ecto.
255 stars 149 forks source link

Replace Arc.Ecto.Schema with importable Arc.Ecto.Changeset #110

Open nsweeting opened 5 years ago

nsweeting commented 5 years ago

This fixes the current dialyzer error, but also cleans up the API and removes the need for cast_attachments/4 to be a macro.

With this new API, one can access the current behaviour with:

defmodule TestUser do
  use Ecto.Schema

  import Ecto.Changeset
  import Arc.Ecto.Changeset

  schema "users" do
    field :first_name, :string
    field :avatar, DummyDefinition.Type
  end

  def changeset(struct, params) do
    struct
    |> cast(params, ~w(first_name)a)
    |> cast_attachments(params, ~w(avatar)a)
  end
end

This, in my mind, makes more sense as we are trying to access a changeset function.

With breaking changes, this would require a version bump.

If this PR is something of interest, I can also update the documentation.

Related to #109 and #106

yordis commented 5 years ago

@stavro can we work on getting this into master and released? 🙏🏻