Let's take it from here...
class WriteFileJob
attr_accessor :dj_id, :file_name
def initialize(file_name)
@file_name = file_name
end
def perform
# do something with @dj_id; don't worry, we'll set it below
end
end
Now when you enqueue the job, you should get a job back:
j = Delayed::Job.enqueue(WriteFileJob.new("foo.txt"))
Next, you load the object that you enqueued, and updated it with the id you just got back:
object_to_update = YAML.load(j.handler)
object_to_update.dj_id = j.id
# update the handler
j.handler = object_to_update.to_yaml
j.save