Class: Metaforce::Job
- Inherits:
-
Object
- Object
- Metaforce::Job
- Defined in:
- lib/metaforce/job.rb
Defined Under Namespace
Classes: CRUD, Deploy, Retrieve
Constant Summary collapse
- DELAY_START =
1
- DELAY_MULTIPLIER =
2
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Public: The id of the AsyncResult returned from Salesforce for this job.
Class Method Summary collapse
Instance Method Summary collapse
-
#done? ⇒ Boolean
Public: Returns true if the job has completed.
-
#initialize(client) ⇒ Job
constructor
Public: Instantiate a new job.
- #inspect ⇒ Object
-
#perform ⇒ Object
Public: Perform the job.
-
#started? ⇒ Boolean
Public: Utility method to determine if .perform has been called yet.
-
#state ⇒ Object
Public: Returns the state if the job has finished processing.
-
#status ⇒ Object
Public: Queries the job status from the API.
Constructor Details
permalink #initialize(client) ⇒ Job
Public: Instantiate a new job. Doesn’t actually do anything until .perform is called.
Examples
job = Metaforce::Job.new(client)
# => #<Metaforce::Job @id=nil>
Returns self.
26 27 28 29 |
# File 'lib/metaforce/job.rb', line 26 def initialize(client) @_callbacks = Hash.new { |h,k| h[k] = [] } @client = client end |
Instance Attribute Details
permalink #id ⇒ Object (readonly)
Public: The id of the AsyncResult returned from Salesforce for this job.
15 16 17 |
# File 'lib/metaforce/job.rb', line 15 def id @id end |
Class Method Details
permalink .disable_threading! ⇒ Object
[View source]
145 146 147 148 149 150 |
# File 'lib/metaforce/job.rb', line 145 def self.disable_threading! ActiveSupport::Deprecation.warn " Metaforce::Job.disable_threading! is deprecated. Use Metaforce.configuration.threading = false instead.\n WARNING\n Metaforce.configuration.threading = false\nend\n".strip_heredoc |
Instance Method Details
permalink #done? ⇒ Boolean
Public: Returns true if the job has completed.
Examples
job.done
# => true
Returns true if the job has completed, false otherwise.
106 107 108 |
# File 'lib/metaforce/job.rb', line 106 def done? status.done end |
permalink #inspect ⇒ Object
[View source]
141 142 143 |
# File 'lib/metaforce/job.rb', line 141 def inspect "#<#{self.class} @id=#{@id.inspect}>" end |
permalink #perform ⇒ Object
Public: Perform the job.
Examples
job = Metaforce::Job.new
job.perform
# => #<Metaforce::Job @id=nil>
Returns self.
40 41 42 43 |
# File 'lib/metaforce/job.rb', line 40 def perform start_heart_beat self end |
permalink #started? ⇒ Boolean
Public: Utility method to determine if .perform has been called yet.
Returns true if @id is set, false otherwise.
48 49 50 |
# File 'lib/metaforce/job.rb', line 48 def started? !!@id end |
permalink #state ⇒ Object
Public: Returns the state if the job has finished processing.
Examples
job.state
# => 'Completed'
Returns the state of the job.
118 119 120 |
# File 'lib/metaforce/job.rb', line 118 def state status.state end |
permalink #status ⇒ Object
Public: Queries the job status from the API.
Examples
job.status
# => { :id => '1234', :done => false, ... }
Returns the AsyncResult (www.salesforce.com/us/developer/docs/api_meta/Content/meta_asyncresult.htm).
94 95 96 |
# File 'lib/metaforce/job.rb', line 94 def status @status ||= client.status(id) end |