Class: Invoicing::CombinedPdfGenerator
- Inherits:
-
BaseService
- Object
- BaseService
- Invoicing::CombinedPdfGenerator
- Defined in:
- app/services/invoicing/combined_pdf_generator.rb
Overview
Service object: combined pdf generator.
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.
11 12 13 14 |
# File 'app/services/invoicing/combined_pdf_generator.rb', line 11 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.
9 10 11 |
# File 'app/services/invoicing/combined_pdf_generator.rb', line 9 def invoice_generator @invoice_generator end |
Instance Method Details
#process(invoice, invoice_options = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/services/invoicing/combined_pdf_generator.rb', line 16 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 |