Extract ActiveJob::Arguments.serialize and deserialize logic

A bit of context

Hi, I am working on an experimental gem based on turbo-rails. It introduces the concept of “widget”, the gem allows rendering a “component” inline (like an ordinary partial) or load it async (with turbo frames). It also groups the controller actions related to the “widget” under the same folder.

As I said, It is experimental; I am testing if the concept works for my projects and learning about the Rails internals.

The serializers

For the async loading, I am serializing the parameters with ActiveJob::Arguments.serialize (plus message_verifier) to pass over query parameters complex objects like AR instances, symbols, time…

I thought it would make sense to extract the ActiveJob::Arguments.serialize/deserialize and the custom serializer logic to a general-purpose package. So other gems, even without rails, could take advantage of this logic.

What do you think?