Module: ActiveModel::Jobs

Defined in:
lib/active_model/jobs.rb,
lib/active_model/jobs/version.rb,
lib/active_model/jobs/performer.rb

Overview

Include this module into your model to take advantage of automatically-generated :#job_name! action methods for any matching ActiveJob classes.

Defined Under Namespace

Classes: Performer

Constant Summary collapse

VERSION =
"0.1.1"

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *arguments) ⇒ Object

Call perform_later on an ActiveJob class corresponding to an undefined action method name. Most of the work here is done in the Performer class, which takes care of discoevering whether the method passed in corresponds to a given job or whether we should just delegate back to ActiveRecord::Base. This method will prevent a new Perfomer class from being instantiated for every method call by using a guard clause to check whether the method is an action method before proceeding on further checks.



23
24
25
26
27
# File 'lib/active_model/jobs.rb', line 23

def method_missing(method, *arguments)
  performer = job_performer(method)
  return super unless performer.present?
  performer.call self
end