Class: Course::Material::ZipDownloadJob

Inherits:
ApplicationJob
  • Object
show all
Includes:
TrackableJob
Defined in:
app/jobs/course/material/zip_download_job.rb

Instance Attribute Summary

Attributes included from TrackableJob

#job

Instance Method Summary collapse

Methods included from TrackableJob

#initialize, #job_id=, #perform, #rescue_tracked, #wait

Instance Method Details

#perform_tracked(folder, materials, filename = folder.name) ⇒ Object (protected)

Performs the download service.

Parameters:

  • folder (Course::Material::Folder)

    The folder containing the materials.

  • materials (Array<Course::Material>)

    The materials to be downloaded.

  • filename (String) (defaults to: folder.name)

    The name of the zip file. This defaults to the name of the folder. This is useful when you don't want to use the name of the folder as the zip filename (such as the root folder).


15
16
17
18
# File 'app/jobs/course/material/zip_download_job.rb', line 15

def perform_tracked(folder, materials, filename = folder.name)
  zip_file = Course::Material::ZipDownloadService.download_and_zip(folder, materials)
  redirect_to SendFile.send_file(zip_file, Pathname.normalize_filename(filename) + '.zip')
end