<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>ActiveJob::Core::ClassMethods</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="../../../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../css/github.css" type="text/css" media="screen" />
<script src="../../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>
    <div class="banner">
        
            <span>Ruby on Rails 4.2.6</span><br />
        
        <h1>
            <span class="type">Module</span>
            ActiveJob::Core::ClassMethods
            
        </h1>
        <ul class="files">
            
            <li><a href="../../../files/__/__/_rbenv/versions/2_4_0/lib/ruby/gems/2_4_0/gems/activejob-4_2_6/lib/active_job/core_rb.html">/home/user/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activejob-4.2.6/lib/active_job/core.rb</a></li>
            
        </ul>
    </div>
    <div id="bodyContent">
        <div id="content">
  
    <div class="description">
      
<p>These methods will be included into any Active Job object, adding helpers
for de/serialization and creation of job instances.</p>

    </div>
  


  


  
  


  


  
    <!-- Method ref -->
    <div class="sectiontitle">Methods</div>
    <dl class="methods">
      
        <dt>D</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="#method-i-deserialize">deserialize</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>S</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="#method-i-set">set</a>
              </li>
            
          </ul>
        </dd>
      
    </dl>
  

  



  

    

    

    


    


    <!-- Methods -->
        
      <div class="sectiontitle">Instance Public methods</div>
      
        <div class="method">
          <div class="title method-title" id="method-i-deserialize">
            
              <b>deserialize</b>(job_data)
            
            <a href="../../../classes/ActiveJob/Core/ClassMethods.html#method-i-deserialize" name="method-i-deserialize" class="permalink">Link</a>
          </div>

          
            <div class="description">
              <p>Creates a new job instance from a hash created with <code>serialize</code></p>
            </div>
          

          

          

          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source:
                <a href="javascript:toggleSource('method-i-deserialize_source')" id="l_method-i-deserialize_source">show</a>
                
              </p>
              <div id="method-i-deserialize_source" class="dyn-source">
                <pre><span class="ruby-comment"># File ../../.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activejob-4.2.6/lib/active_job/core.rb, line 27</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">deserialize</span>(<span class="ruby-identifier">job_data</span>)
  <span class="ruby-identifier">job</span>                      = <span class="ruby-identifier">job_data</span>[<span class="ruby-string">&#39;job_class&#39;</span>].<span class="ruby-identifier">constantize</span>.<span class="ruby-identifier">new</span>
  <span class="ruby-identifier">job</span>.<span class="ruby-identifier">job_id</span>               = <span class="ruby-identifier">job_data</span>[<span class="ruby-string">&#39;job_id&#39;</span>]
  <span class="ruby-identifier">job</span>.<span class="ruby-identifier">queue_name</span>           = <span class="ruby-identifier">job_data</span>[<span class="ruby-string">&#39;queue_name&#39;</span>]
  <span class="ruby-identifier">job</span>.<span class="ruby-identifier">serialized_arguments</span> = <span class="ruby-identifier">job_data</span>[<span class="ruby-string">&#39;arguments&#39;</span>]
  <span class="ruby-identifier">job</span>.<span class="ruby-identifier">locale</span>               = <span class="ruby-identifier">job_data</span>[<span class="ruby-string">&#39;locale&#39;</span>] <span class="ruby-operator">||</span> <span class="ruby-constant">I18n</span>.<span class="ruby-identifier">locale</span>
  <span class="ruby-identifier">job</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-set">
            
              <b>set</b>(options={})
            
            <a href="../../../classes/ActiveJob/Core/ClassMethods.html#method-i-set" name="method-i-set" class="permalink">Link</a>
          </div>

          
            <div class="description">
              <p>Creates a job preconfigured with the given options. You can call
perform_later with the job arguments to enqueue the job with the
preconfigured options</p>

<h4 id="method-i-set-label-Options">Options</h4>
<ul><li>
<p><code>:wait</code> - Enqueues the job with the specified delay</p>
</li><li>
<p><code>:wait_until</code> - Enqueues the job at the time specified</p>
</li><li>
<p><code>:queue</code> - Enqueues the job on the specified queue</p>
</li></ul>

<h4 id="method-i-set-label-Examples">Examples</h4>

<pre><code>VideoJob.set(queue: :some_queue).perform_later(Video.last)
VideoJob.set(wait: 5.minutes).perform_later(Video.last)
VideoJob.set(wait_until: Time.now.tomorrow).perform_later(Video.last)
VideoJob.set(queue: :some_queue, wait: 5.minutes).perform_later(Video.last)
VideoJob.set(queue: :some_queue, wait_until: Time.now.tomorrow).perform_later(Video.last)
</code></pre>
            </div>
          

          

          

          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source:
                <a href="javascript:toggleSource('method-i-set_source')" id="l_method-i-set_source">show</a>
                
              </p>
              <div id="method-i-set_source" class="dyn-source">
                <pre><span class="ruby-comment"># File ../../.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activejob-4.2.6/lib/active_job/core.rb, line 52</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">set</span>(<span class="ruby-identifier">options</span>={})
  <span class="ruby-constant">ConfiguredJob</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword">self</span>, <span class="ruby-identifier">options</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
                    </div>

    </div>
  </body>
</html>
