Active Job/GlobalID custom types

Hi all,

We just updated our app to rails 4.2, and implemented ActiveJob for our
background jobs (were using Resque). I’ve read the docs and the code,
and I
couldn’t find a “best practice” to accept custom types as job arguments.

I’ve managed to make a class serializable by mixing in
GlobalID::Identification and implementing .find and #id methods. But
then I
started to have more errors, particularly with BigDecimal and
ActiveRecord::AssociationRelation parameters.

The quick fix was to create an initializer and reopen
ActiveJob::Arguments
to override the serialize_argument method and accept those methods. I
know
it’s not the best option as for example relation arguments would get
converted to an array and it could be a lot of records.

So I wanted to know your opinion and how would you do it.

Other possible solution would be just to get the id of each record in
the
relation ( .pluck(:id) ) and then finding each record in the job worker
again, but then what would be the point of having ActiveJob
serialization?

Cheers!

Ok, I kind of found the solution using callbacks
https://gist.github.com/edgarjs/0d24a8b36bbf7e7d11c3, but still
there’s
the problem for executing all the relation that may be too big.

Any idea?

cheers