Sha256: c2f13c32631042719b83bf6cfe4b0b24a0c69c63d84b23924d3f1041b571a11c

Contents?: true

Size: 826 Bytes

Versions: 95

Compression:

Stored size: 826 Bytes

Contents

# frozen_string_literal: true

require_dependency "renalware/events"
require "fileutils"

module Renalware
  module Events
    # Used for example in a host app like renalware-kch to generate a PDF event for saving to
    # the electronic public register
    class SavePdfEventToFileJob < ApplicationJob
      queue_as :pdf_generation
      queue_with_priority 1

      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

      def pdf_data_for(event)
        decorated_event = EventPdfPresenter.new(event)
        EventPdf.new(decorated_event).render
      end

      def create_folder_if_not_exists(path)
        FileUtils.mkdir_p(path.dirname)
      end
    end
  end
end

Version data entries

95 entries across 95 versions & 1 rubygems

Version Path
renalware-core-2.1.1 app/jobs/renalware/events/save_pdf_event_to_file_job.rb
renalware-core-2.1.0 app/jobs/renalware/events/save_pdf_event_to_file_job.rb
renalware-core-2.0.167 app/jobs/renalware/events/save_pdf_event_to_file_job.rb
renalware-core-2.0.166 app/jobs/renalware/events/save_pdf_event_to_file_job.rb
renalware-core-2.0.165 app/jobs/renalware/events/save_pdf_event_to_file_job.rb
renalware-core-2.0.164 app/jobs/renalware/events/save_pdf_event_to_file_job.rb
renalware-core-2.0.163 app/jobs/renalware/events/save_pdf_event_to_file_job.rb
renalware-core-2.0.162 app/jobs/renalware/events/save_pdf_event_to_file_job.rb
renalware-core-2.0.161 app/jobs/renalware/events/save_pdf_event_to_file_job.rb
renalware-core-2.0.160 app/jobs/renalware/events/save_pdf_event_to_file_job.rb
renalware-core-2.0.159 app/jobs/renalware/events/save_pdf_event_to_file_job.rb
renalware-core-2.0.158 app/jobs/renalware/events/save_pdf_event_to_file_job.rb
renalware-core-2.0.157 app/jobs/renalware/events/save_pdf_event_to_file_job.rb
renalware-core-2.0.156 app/jobs/renalware/events/save_pdf_event_to_file_job.rb
renalware-core-2.0.155 app/jobs/renalware/events/save_pdf_event_to_file_job.rb
renalware-core-2.0.153 app/jobs/renalware/events/save_pdf_event_to_file_job.rb
renalware-core-2.0.152 app/jobs/renalware/events/save_pdf_event_to_file_job.rb
renalware-core-2.0.151 app/jobs/renalware/events/save_pdf_event_to_file_job.rb
renalware-core-2.0.149 app/jobs/renalware/events/save_pdf_event_to_file_job.rb
renalware-core-2.0.148 app/jobs/renalware/events/save_pdf_event_to_file_job.rb