mirror of
https://github.com/internetee/registry.git
synced 2025-06-08 21:54:48 +02:00
- Remove `Que::Mailer` (#895) - Extract controllers - Extract translations - Convert HAML to ERB - Add mailer preview - Improve UI - Remove unused routes - Add tests
22 lines
No EOL
457 B
Ruby
22 lines
No EOL
457 B
Ruby
class Invoice
|
|
class PdfGenerator
|
|
attr_reader :invoice
|
|
|
|
def initialize(invoice)
|
|
@invoice = invoice
|
|
end
|
|
|
|
def as_pdf
|
|
generator = PDFKit.new(invoice_html)
|
|
generator.to_pdf
|
|
end
|
|
|
|
private
|
|
|
|
def invoice_html
|
|
view = ActionView::Base.new(ActionController::Base.view_paths, invoice: invoice)
|
|
view.class_eval { include ApplicationHelper }
|
|
view.render(file: 'invoice/pdf', layout: false)
|
|
end
|
|
end
|
|
end |