module Quebert::AsyncSender::Instance::ClassMethods

Public Instance Methods

overwrite_initialize() click to toggle source

Hack into the class initialize method so that we can grab the arguments used to create an instance of the class that we can serialize into a job.

# File lib/quebert/async_sender/instance.rb, line 46
def overwrite_initialize
  class_eval do
    unless method_defined?(:initialize_with_async_sender)
      define_method(:initialize_with_async_sender) do
        initialize_without_async_sender
      end
    end
    
    if instance_method(:initialize) != instance_method(:initialize_with_async_sender)
      alias_method :initialize_without_async_sender, :initialize
      alias_method :initialize, :initialize_with_async_sender
    end
  end
end