config/initializers/wrappers/jobs/single_method_job.rb in eitil-0.3.4 vs config/initializers/wrappers/jobs/single_method_job.rb in eitil-0.3.5
- old
+ new
@@ -1,10 +1,26 @@
module Eitil
class SingleMethodJob < ApplicationJob
queue_as :default
- def perform(_class:, _method:, id: nil)
- object = id ? _class.constantize.find(id) : _class.constantize
+ # BEWARE: _self is currently not accepted in perform_later jobs due to serialization errors
+
+ # The cases of 'id' and '_self' both handle instances, with the difference
+ # being that 'id' works for objects that have a database record, while '_self'
+ # works for non database supported instanes, such as an Exporter instance.
+
+ def perform(_class:, _method:, id: nil, _self: nil)
+ binding.pry
+
+ object =
+ if id
+ _class.constantize.find(id)
+ elsif _self
+ _self
+ else
+ _class.constantize
+ end
+
object.send _method
end
end
end