lib/para/exporter/csv.rb in para-0.6.2 vs lib/para/exporter/csv.rb in para-0.6.3

- old
+ new

@@ -1,34 +1,29 @@ require 'csv' module Para module Exporter class Csv < Base - register_base_exporter :csv, self - - def extension - 'csv' - end - - def mime_type - 'text/csv' - end - - def export_type - :excel - end - def render - CSV.generate do |csv| + data = CSV.generate do |csv| csv << headers resources.each do |resource| csv << row_for(resource) end end + + Tempfile.new([name, extension]).tap do |file| + file.write(data) + file.rewind + end end private + + def extension + '.csv' + end def headers fields.map do |field| encode(model.human_attribute_name(field)) end