Class: Invoicing::CombinedPdfGenerator
- Inherits:
-
BaseService
- Object
- BaseService
- Invoicing::CombinedPdfGenerator
- Defined in:
- app/services/invoicing/combined_pdf_generator.rb
Defined Under Namespace
Classes: Result
Instance Attribute Summary collapse
-
#invoice_generator ⇒ Object
readonly
Returns the value of attribute invoice_generator.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ CombinedPdfGenerator
constructor
A new instance of CombinedPdfGenerator.
- #process(invoice, invoice_options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ CombinedPdfGenerator
Returns a new instance of CombinedPdfGenerator.
8 9 10 11 |
# File 'app/services/invoicing/combined_pdf_generator.rb', line 8 def initialize( = {}) @invoice_generator = [:invoice_generator] || Invoicing::PdfGenerator.new() super end |
Instance Attribute Details
#invoice_generator ⇒ Object (readonly)
Returns the value of attribute invoice_generator.
6 7 8 |
# File 'app/services/invoicing/combined_pdf_generator.rb', line 6 def invoice_generator @invoice_generator end |
Instance Method Details
#process(invoice, invoice_options = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/services/invoicing/combined_pdf_generator.rb', line 13 def process(invoice, = {}) = .reverse_merge({ output_to_file: true }) combined_pdf = invoice_generator.process(invoice, {}) result_hsh = { options: , file_name: invoice.file_name } if [:output_to_file] result_hsh[:pdf_file_path] = [:output_to_file_path] || File.join(Rails.application.config.x.temp_storage_path.to_s, result_hsh[:file_name]) combined_pdf.save result_hsh[:pdf_file_path] else # Stream result_hsh[:pdf_data] = combined_pdf.to_pdf end Result.new(**result_hsh) end |