Class: Resque::Reports::ReportJob

Inherits:
Object
  • Object
show all
Includes:
Integration
Defined in:
app/jobs/resque/reports/report_job.rb

Overview

ReportJob accepts report_type and current report arguments to build it in background

Class Method Summary collapse

Class Method Details

.execute(report_type, args_json) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'app/jobs/resque/reports/report_job.rb', line 11

def self.execute(report_type, args_json)
  report_class = constant(report_type) # Get report class from string (through ActiveSupport)
  raise "Resque::Reports::ReportJob can work only with successors of Resque::Reports::BaseReport, but got #{report_class}" unless report_class.ancestors.include? BaseReport

  args = Json.parse(args_json)
  report = report_class.new *args

  report.build
end