Module: Concerns::SendOrderPdf

Extended by:
ActiveSupport::Concern
Included in:
OrdersController
Defined in:
app/controllers/concerns/send_order_pdf.rb

Instance Method Summary collapse

Instance Method Details

#send_order_pdf(order, document) ⇒ Object (protected)



6
7
8
9
10
11
12
13
14
15
# File 'app/controllers/concerns/send_order_pdf.rb', line 6

def send_order_pdf(order, document)
  klass = case document
          when 'groups'   then OrderByGroups
          when 'articles' then OrderByArticles
          when 'fax'      then OrderFax
          when 'matrix'   then OrderMatrix
          end
  pdf = klass.new order
  send_data pdf.to_pdf, filename: pdf.filename, type: 'application/pdf'
end