config/initializers/wrappers/jobs/active_job_macros.rb in eitil-0.3.4 vs config/initializers/wrappers/jobs/active_job_macros.rb in eitil-0.3.5
- old
+ new
@@ -1,11 +1,17 @@
Kernel.module_eval do
+ # 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 new_job(_method)
if instance_methods(false).include? _method
- define_method "#{_method}_job" do
- Eitil::SingleMethodJob.perform_later(_class: self.class.to_s, _method: _method.to_s, id: id)
+ define_method "#{_method}_job" do |_self = nil|
+ Eitil::SingleMethodJob.perform_later(_class: self.class.to_s, _method: _method.to_s, id: safe_send(:id), _self: self.to_json)
end
elsif singleton_methods(false).include? _method
define_singleton_method "#{_method}_job" do
Eitil::SingleMethodJob.perform_later(_class: to_s, _method: _method.to_s)
\ No newline at end of file