Class: Marty::JobController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/marty/job_controller.rb

Instance Method Summary collapse

Instance Method Details

#downloadObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/marty/job_controller.rb', line 2

def download
  job_id = params["job_id"]

  promise = Marty::Promise.find_by_id(job_id)

  if promise
    format = promise.cformat
    # somewhat hacky: if result has "result" key, it's used as the
    # content.
    data = promise.result["result"] || promise.result
    title = promise.title
  else
    format = "json"
    data = {error: "Job not found: #{job_id}"}
    title = "error"
  end

  res, type, disposition, filename =
    Marty::ContentHandler.export(data, format, title)

  send_data(res,
            type:        type,
            filename:    filename,
            disposition: disposition,
            )
end