Class: Metaforce::Job::Retrieve
- Inherits:
-
Metaforce::Job
- Object
- Metaforce::Job
- Metaforce::Job::Retrieve
- Defined in:
- lib/metaforce/job/retrieve.rb
Constant Summary
Constants inherited from Metaforce::Job
Instance Attribute Summary
Attributes inherited from Metaforce::Job
Instance Method Summary collapse
-
#extract_to(destination) ⇒ Object
Public: Unzips the returned zip file to the location.
-
#initialize(client, options = {}) ⇒ Retrieve
constructor
Public: Instantiate a new retrieve job.
-
#perform ⇒ Object
Public: Perform the job.
-
#result ⇒ Object
Public: Get the detailed status of the retrieve.
-
#zip_file ⇒ Object
Public: Decodes the content of the returned zip file.
Methods inherited from Metaforce::Job
disable_threading!, #done?, #inspect, #started?, #state, #status
Constructor Details
permalink #initialize(client, options = {}) ⇒ Retrieve
12 13 14 15 |
# File 'lib/metaforce/job/retrieve.rb', line 12 def initialize(client, ={}) super(client) @options = end |
Instance Method Details
permalink #extract_to(destination) ⇒ Object
Public: Unzips the returned zip file to the location.
destination - Path to extract the contents to.
Examples
job.extract_to('./path')
# => #<Metaforce::Job::Retrieve @id='1234'>
Returns self.
65 66 67 68 69 70 71 |
# File 'lib/metaforce/job/retrieve.rb', line 65 def extract_to(destination) return on_complete { |job| job.extract_to(destination) } unless started? with_tmp_zip_file do |file| unzip(file, destination) end self end |
permalink #perform ⇒ Object
26 27 28 29 |
# File 'lib/metaforce/job/retrieve.rb', line 26 def perform @id = client._retrieve(@options).id super end |
permalink #result ⇒ Object
Public: Get the detailed status of the retrieve.
Examples
job.result
# => { :id => '1234', :zip_file => '<base64 encoded content>', ... }
Returns the RetrieveResult (www.salesforce.com/us/developer/docs/api_meta/Content/meta_retrieveresult.htm).
39 40 41 |
# File 'lib/metaforce/job/retrieve.rb', line 39 def result @result ||= client.status(id, :retrieve) end |
permalink #zip_file ⇒ Object
Public: Decodes the content of the returned zip file.
Examples
job.zip_file
# => '<binary content>'
Returns the decoded content.
51 52 53 |
# File 'lib/metaforce/job/retrieve.rb', line 51 def zip_file Base64.decode64(result.zip_file) end |