Sha256: 031e1845a9fefd6f0006e05905ca64a2ce43cfec9c45927e8c6d8e74a242b29f

Contents?: true

Size: 1.07 KB

Versions: 70

Compression:

Stored size: 1.07 KB

Contents

# require "eitil_wrapper/jobs/new_job"

require "eitil_wrapper/jobs/single_method_job"

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, *args, **kwargs)

    if instance_methods(false).include? _method
      define_method "#{_method}_job" do |_self = nil, *args, **kwargs|
        
        EitilWrapper::SingleMethodJob.perform_later(
          *args, _class: self.class.to_s, _method: _method.to_s, id: safe_send(:id), _self: self.to_json, **kwargs
        )
      end

    elsif singleton_methods(false).include? _method      
      define_singleton_method "#{_method}_job" do |*args, **kwargs|
       
        EitilWrapper::SingleMethodJob.perform_later(
          *args, _class: to_s, _method: _method.to_s, **kwargs
        )
      end
    end 
  end

end

Version data entries

70 entries across 70 versions & 1 rubygems

Version Path
eitil-2.0.2 eitil_wrapper/lib/eitil_wrapper/jobs/new_job.rb
eitil-2.0.1 eitil_wrapper/lib/eitil_wrapper/jobs/new_job.rb
eitil-2.0.0 eitil_wrapper/lib/eitil_wrapper/jobs/new_job.rb
eitil-1.4.1 eitil_wrapper/lib/eitil_wrapper/jobs/new_job.rb
eitil-1.4.0 eitil_wrapper/lib/eitil_wrapper/jobs/new_job.rb
eitil-1.3.12 eitil_wrapper/lib/eitil_wrapper/jobs/new_job.rb
eitil-1.3.11 eitil_wrapper/lib/eitil_wrapper/jobs/new_job.rb
eitil-1.3.10 eitil_wrapper/lib/eitil_wrapper/jobs/new_job.rb
eitil-1.3.9 eitil_wrapper/lib/eitil_wrapper/jobs/new_job.rb
eitil-1.3.8 eitil_wrapper/lib/eitil_wrapper/jobs/new_job.rb
eitil-1.3.7 eitil_wrapper/lib/eitil_wrapper/jobs/new_job.rb
eitil-1.3.6 eitil_wrapper/lib/eitil_wrapper/jobs/new_job.rb
eitil-1.3.5 eitil_wrapper/lib/eitil_wrapper/jobs/new_job.rb
eitil-1.3.4 eitil_wrapper/lib/eitil_wrapper/jobs/new_job.rb
eitil-1.3.3 eitil_wrapper/lib/eitil_wrapper/jobs/new_job.rb
eitil-1.3.2 eitil_wrapper/lib/eitil_wrapper/jobs/new_job.rb
eitil-1.3.1 eitil_wrapper/lib/eitil_wrapper/jobs/new_job.rb
eitil-1.3.0 eitil_wrapper/lib/eitil_wrapper/jobs/new_job.rb
eitil-1.2.4 eitil_wrapper/lib/eitil_wrapper/jobs/new_job.rb
eitil-1.2.3 eitil_wrapper/lib/eitil_wrapper/jobs/new_job.rb