Module: Stenotype::Frameworks::Rails::ActiveJobExtension
- Defined in:
- lib/stenotype/frameworks/rails/active_job.rb
Overview
An extension for ActiveJob to enable adding a hook before performing an instance of [ActiveJob::Base] subclass
Instance Method Summary collapse
Instance Method Details
#trackable_job! ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/stenotype/frameworks/rails/active_job.rb', line 33 def trackable_job! proxy = const_get(:JobExt) proxy.module_eval do define_method(:perform) do |*args, **rest_args, &block| Stenotype::Event.emit!( "active_job_#{self.class.name}", { type: "active_job" }, **{ eval_context: { active_job: self }}, ) super(*args, **rest_args, &block) end end # Prepend an instance of module so that # super() can be chained down the ancestors # without changing existing ActiveJob interface # public_send(:prepend, proxy) end |