Currently MapRewire returns both the original map and the new map. This means we need to create boilerplate to be able to use MapRewire in a pipeline:
def changeset(variant, params) do
variant
|> normalize_data()
|> cast(
params,
~w(shopify_id title price weight compare_at_price requires_shipping sku available image_id option1 option2 option3)
)
end
defp normalize_data(data) do
[_old, new] = data <~> @transforms
new
end
To reduce the amount of boilerplate needed to use MapRewire we should consider creating a normalize_data function that can be used in a typical changeset:
def changeset(variant, params) do
variant
|> normalize_data(params, @transforms)
|> cast(
params,
~w(shopify_id title price weight compare_at_price requires_shipping sku available image_id option1 option2 option3)
)
end
Currently MapRewire returns both the original map and the new map. This means we need to create boilerplate to be able to use MapRewire in a pipeline:
To reduce the amount of boilerplate needed to use MapRewire we should consider creating a
normalize_datafunction that can be used in a typical changeset: