Class: Renalware::Events::SavePdfEventToFileJob
- Inherits:
-
ApplicationJob
- Object
- ActiveJob::Base
- ApplicationJob
- Renalware::Events::SavePdfEventToFileJob
- Defined in:
- app/jobs/renalware/events/save_pdf_event_to_file_job.rb
Overview
Used for example in a host app like renalware-kch to generate a PDF event for saving to the electronic public register
Instance Method Summary collapse
- #create_folder_if_not_exists(path) ⇒ Object
- #pdf_data_for(event) ⇒ Object
- #perform(event:, file_path:) ⇒ Object
Instance Method Details
#create_folder_if_not_exists(path) ⇒ Object
25 26 27 |
# File 'app/jobs/renalware/events/save_pdf_event_to_file_job.rb', line 25 def create_folder_if_not_exists(path) FileUtils.mkdir_p(path.dirname) end |
#pdf_data_for(event) ⇒ Object
20 21 22 23 |
# File 'app/jobs/renalware/events/save_pdf_event_to_file_job.rb', line 20 def pdf_data_for(event) decorated_event = EventPdfPresenter.new(event) EventPdf.new(decorated_event).render end |
#perform(event:, file_path:) ⇒ Object
14 15 16 17 18 |
# File 'app/jobs/renalware/events/save_pdf_event_to_file_job.rb', line 14 def perform(event:, file_path:) file_path = Pathname(file_path) create_folder_if_not_exists(file_path) File.open(file_path, "wb") { |file| file << pdf_data_for(event) } end |