123456789_123456789_123456789_123456789_123456789_

Module: ActiveJob::Core

Relationships & Source Files
Namespace Children
Modules:
Extension / Inclusion / Inheritance Descendants
Included In:
ActionMailer::DeliveryJob, Base
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Defined in: activejob/lib/active_job/core.rb

Class Method Summary

Instance Method Summary

DSL Calls

included

[ GitHub ]


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'activejob/lib/active_job/core.rb', line 5

included do
  # Job arguments
  attr_accessor :arguments
  attr_writer :serialized_arguments

  # Timestamp when the job should be performed
  attr_accessor :scheduled_at

  # Job Identifier
  attr_accessor :job_id

  # Queue in which the job will reside.
  attr_writer :queue_name

  # I18n.locale to be used during the job.
  attr_accessor :locale
end

Instance Method Details

#initialize(*arguments)

Creates a new job instance. Takes the arguments that will be passed to the perform method.

[ GitHub ]

  
# File 'activejob/lib/active_job/core.rb', line 59

def initialize(*arguments)
  @arguments  = arguments
  @job_id     = SecureRandom.uuid
  @queue_name = self.class.queue_name
end

#serialize

Returns a hash with the job data that can safely be passed to the queueing adapter.

[ GitHub ]

  
# File 'activejob/lib/active_job/core.rb', line 67

def serialize
  {
    'job_class'  => self.class.name,
    'job_id'     => job_id,
    'queue_name' => queue_name,
    'arguments'  => serialize_arguments(arguments),
    'locale'     => I18n.locale
  }
end