class Base
Ruby on Rails 4.2.9
Since v4.2.9Active Job
Active Job objects can be configured to work with different backend queuing frameworks. To specify a queue adapter to use:
ActiveJob::Base.queue_adapter = :inline
A list of supported adapters can be found in QueueAdapters.
Active Job objects can be defined by creating a class that inherits from the ActiveJob::Base class. The only necessary method to implement is the “perform” method.
To define an Active Job object:
class ProcessPhotoJob < ActiveJob::Base
def perform(photo)
photo.watermark!('Rails')
photo.rotate!(90.degrees)
photo.resize_to_fit!(300, 300)
photo.upload!
end
end
Records that are passed in are serialized/deserialized using Global ID. More information can be found in Arguments.
To enqueue a job to be performed as soon the queueing system is free:
ProcessPhotoJob.perform_later(photo)
To enqueue a job to be processed at some point in the future:
ProcessPhotoJob.set(wait_until: Date.tomorrow.noon).perform_later(photo)
More information can be found in ActiveJob::Core::ClassMethods#set
A job can also be processed immediately without sending to the queue:
ProcessPhotoJob.perform_now(photo)
Exceptions
-
DeserializationError- Error class for deserialization errors. -
SerializationError- Error class for serialization errors.
Inherits from
Includes
Methods (inherited)
From ActiveJob::Execution
(2)
- # perform
- # perform_now
From ActiveJob::QueueName
(1)
From Object
(23)
- # <
- # acts_like?
- # blank?
- # create_fixtures
- # deep_dup
- # destroy
- # duplicable?
- # html_safe?
- # in?
- # instance_values
- # instance_variable_names
- # itself
- # perform
- # presence
- # presence_in
- # present?
- # to_param
- # to_query
- # try
- # try!
- # unescape
- # with_options
- self. table_name_prefix
From ActiveSupport::Callbacks
(1)
From ActiveSupport::Concern
(3)
From ActiveSupport::Rescuable
(2)
From ActiveSupport::DescendantsTracker
(7)
- # descendants
- # direct_descendants
- # inherited
- self. clear
- self. descendants
- self. direct_descendants
- self. store_inherited