module ActiveJob::Core
def deserialize(job_data)
end
retry_job(wait: 10)
raise exception if @attempt_number > 5
rescue_from(TimeoutError) do |exception|
end
@attempt_number = job_data['attempt_number']
super
def deserialize(job_data)
end
super.merge('attempt_number' => (@attempt_number || 0) + 1)
def serialize
class DeliverWebhookJob < ActiveJob::Base
==== Examples
returned from +serialize+
Attaches the stored job data to the current instance. Receives a hash
def deserialize(job_data) self.job_id = job_data["job_id"] self.provider_job_id = job_data["provider_job_id"] self.queue_name = job_data["queue_name"] self.priority = job_data["priority"] self.serialized_arguments = job_data["arguments"] self.executions = job_data["executions"] self.locale = job_data["locale"] || I18n.locale.to_s end
def deserialize_arguments(serialized_args)
def deserialize_arguments(serialized_args) Arguments.deserialize(serialized_args) end
def deserialize_arguments_if_needed
def deserialize_arguments_if_needed if defined?(@serialized_arguments) && @serialized_arguments.present? @arguments = deserialize_arguments(@serialized_arguments) @serialized_arguments = nil end end
def initialize(*arguments)
Creates a new job instance. Takes the arguments that will be
def initialize(*arguments) @arguments = arguments @job_id = SecureRandom.uuid @queue_name = self.class.queue_name @priority = self.class.priority @executions = 0 end
def serialize
Returns a hash with the job data that can safely be passed to the
def serialize { "job_class" => self.class.name, "job_id" => job_id, "provider_job_id" => provider_job_id, "queue_name" => queue_name, "priority" => priority, "arguments" => serialize_arguments(arguments), "executions" => executions, "locale" => I18n.locale.to_s } end
def serialize_arguments(serialized_args)
def serialize_arguments(serialized_args) Arguments.serialize(serialized_args) end