Closed summera closed 4 years ago
@ixti provided everything here is all good, can we also backport this to v4.x
?
@ixti just wanted to check back with you on this. Let me know what you think.
Honestly I think it's better to check type. But I agree that checking multiple types in here is kinda ugly. So I tend to think that we can add coerce
to FormData
instead and use it here instead of create
. WDYT?
@ixti thanks for the merge and apologies for not getting back to you earlier with my thoughts! Any chance of backporting this update to 4.x?
Sorry, just realized it already was! Great 👍 . Please let me know when a new release is out with the update 😄
Released v4.4.0
As discussed with @ixti in https://github.com/httprb/form_data/pull/29, this allows you to pass an
HTTP::FormData
object directly instead of aHash
for more customization such as using a custom encoder. Example:Note that I decided to use the following logic to determine whether an
HTTP::FormData
object was being passed in directly:The other option would be to check if
form
is_a?
HTTP::FormData::Urlencoded
or aHTTP::FormData::Multipart
but this seemed less flexible since it creates a coupling with what's returned fromHTTP::FormData.create
. However, I don't have a strong opinion here and am happy to change if another method is more desirable.