Class: ActiveJob::QueueAdapters::TestAdapter
- Inherits:
-
Object
- Object
- ActiveJob::QueueAdapters::TestAdapter
- Defined in:
- lib/batch_processor/rspec/active_job_test_adapter_monkeypatch.rb
Instance Method Summary collapse
-
#job_to_hash(job, extras = {}) ⇒ Object
BatchProcessor relies on serialized arguments being passed to ActiveJob, as the batch_id is put into the serialized hash to keep it out of the arguments and prevent needing a deeper override of ActiveJob’s API.
Instance Method Details
#job_to_hash(job, extras = {}) ⇒ Object
BatchProcessor relies on serialized arguments being passed to ActiveJob, as the batch_id is put into the serialized hash to keep it out of the arguments and prevent needing a deeper override of ActiveJob’s API. This works totally fine and perfect when you are using the test adapter and processing the jobs, as the internal implementation is to just call ActiveJob::Base.execute on the serialized hash. Weirdly, instead of… just putting the serialized hash into an array and using that, the implementation literally reinvents a simpler wheel WHILE USING THE ACTUAL SERIALIZED HASH ITSELF TO EXTRACT ARGUMENTS. So like… I changed that.
There didn’t seem to be a value to me to put this implementation in a way which keeps the original API because the actual serialized API itself is so similar, refactoring any test implementation to work with the change should be trivial.
16 17 18 |
# File 'lib/batch_processor/rspec/active_job_test_adapter_monkeypatch.rb', line 16 def job_to_hash(job, extras = {}) job.serialize.merge!(extras) end |