class Dossier::Responder
Public Instance Methods
respond()
click to toggle source
Calls superclass method
# File lib/dossier/responder.rb, line 26 def respond multi_report_html_only! super end
to_csv()
click to toggle source
# File lib/dossier/responder.rb, line 16 def to_csv set_content_disposition! controller.response_body = StreamCSV.new(*collection_and_headers(report.raw_results.arrays)) end
to_html()
click to toggle source
# File lib/dossier/responder.rb, line 7 def to_html report.renderer.engine = controller controller.response_body = report.render end
to_json()
click to toggle source
# File lib/dossier/responder.rb, line 12 def to_json controller.render json: report.results.hashes end
to_xls()
click to toggle source
# File lib/dossier/responder.rb, line 21 def to_xls set_content_disposition! controller.response_body = Xls.new(*collection_and_headers(report.raw_results.arrays)) end
Private Instance Methods
collection_and_headers(collection)
click to toggle source
# File lib/dossier/responder.rb, line 37 def collection_and_headers(collection) headers = collection.shift.map { |header| report.format_header(header) } [collection, headers] end
filename()
click to toggle source
# File lib/dossier/responder.rb, line 42 def filename "#{report.class.filename}.#{format}" end
multi_report_html_only!()
click to toggle source
# File lib/dossier/responder.rb, line 46 def multi_report_html_only! if report.is_a?(Dossier::MultiReport) and format.to_s != 'html' raise Dossier::MultiReport::UnsupportedFormatError.new(format) end end
set_content_disposition!()
click to toggle source
# File lib/dossier/responder.rb, line 33 def set_content_disposition! controller.headers["Content-Disposition"] = %[attachment;filename=#{filename}] end