title: How to reference active delayed_job within the actual job
body: <p>I am working on a solution to display the percentage completion of a delayed job (using the delayed_job gem). At the present, I have a database migration that looks like the following for my delayed_jobs table:</p>
  
  <pre><code>class CreateDelayedJobs &lt; ActiveRecord::Migration
    def self.up
      create_table :delayed_jobs, :force =&gt; true do |table|
        table.integer  :priority, :default =&gt; 0      # Allows some jobs to jump to the front of the queue
        table.integer  :attempts, :default =&gt; 0      # Provides for retries, but still fail eventually.
        table.text     :handler                      # YAML-encoded string of the object that will do work
        table.text     :last_error                   # reason for last failure (See Note below)
        table.datetime :run_at                       # When to run. Could be Time.zone.now for immediately, or sometime in the future.
        table.datetime :locked_at                    # Set when a client is working on this object
        table.datetime :failed_at                    # Set when all retries have failed (actually, by default, the record is deleted instead)
        table.string   :locked_by                    # Who is working on this object (if locked)
        table.string   :queue                        # The name of the queue this job is in
        table.integer  :progress
        table.timestamps
  
      end
  
      add_index :delayed_jobs, [:priority, :run_at], :name =&gt; 'delayed_jobs_priority'
    end
  
    def self.down
      drop_table :delayed_jobs
    end
  end
  </code></pre>
  
  <p>I am using an enqueue process within a controller method for a delayed job, and referencing a class in lib/build_detail.rb :</p>
  
  <pre><code>Delayed::Job.enqueue(BuildDetail.new(@object, @com))
  </code></pre>
  
  <p>The lib/build_detail.rb file is as follows:</p>
  
  <pre><code>class BuildDetail &lt; Struct.new(:object, :com)
  
    def perform
      total_count = object.person_ids.length
      progress_count = 0
  
      people = com.person object.person_ids do |abc|
        progress_count += abc.size
        Delayed::Job.current.update_attribute :progress, (progress_count/total_count)
      end
    end  
  
  end
  </code></pre>
  
  <p>Delayed::Job.current doesn't work. I see the Delayed::Job.current method proposed on <a href="https://groups.google.com/forum/?fromgroups=#!topic/sdruby/0OIj0XKsnrg" rel="noreferrer">this posting</a>, however it looks like the method was never included in the main delayed_jobs github project.</p>
  
  <p>How can I access the current job (from within the actual job), to update the progress field each time my job goes through the loop? </p>