Class: Resque::Reports::BaseReport
- Inherits:
-
Object
- Object
- Resque::Reports::BaseReport
- Extended by:
- Forwardable
- Includes:
- Encodings
- Defined in:
- lib/resque/reports/base_report.rb
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_EXTENSION =
Constants
'txt'
Instance Method Summary collapse
- #bg_build ⇒ Object
- #build ⇒ Object
-
#initialize(*args) ⇒ BaseReport
constructor
Public instance methods.
Methods included from Encodings
Constructor Details
#initialize(*args) ⇒ BaseReport
Public instance methods
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/resque/reports/base_report.rb', line 60 def initialize(*args) create_block.call(*args) if create_block @args = args extension ||= DEFAULT_EXTENSION @cache_file = CacheFile.new(directory, generate_filename, coding: encoding) init_table end |
Instance Method Details
#bg_build ⇒ Object
75 76 77 78 79 80 81 82 83 84 |
# File 'lib/resque/reports/base_report.rb', line 75 def bg_build report_class = self.class.to_s args_json = @args.to_json # Check report if it already in progress and tring return its job_id... job_id = ReportJob.enqueued?(report_class, args_json).try(:meta_id) # ...and start new job otherwise ReportJob.enqueue(report_class, args_json) unless job_id end |
#build ⇒ Object
71 72 73 |
# File 'lib/resque/reports/base_report.rb', line 71 def build @cache_file.open { |file| write file } end |