Sha256: d0433313396401b55ff58ad7326c95b9fa95db6ec09172fae477d197de089f8f
Contents?: true
Size: 869 Bytes
Versions: 17
Compression:
Stored size: 869 Bytes
Contents
module ActiveList module Exporters class CsvExporter < AbstractExporter def file_extension "csv" end def mime_type Mime::CSV end def send_data_code record = "r" code = generator.select_data_code(paginate: false) code << "data = ::CSV.generate do |csv|\n" code << " csv << [#{columns_to_array(:header).join(', ')}]\n" code << " for #{record} in #{generator.records_variable_name}\n" code << " csv << [#{columns_to_array(:body, record: record).join(', ')}]\n" code << " end\n" code << "end\n" code << "send_data(data, type: #{self.mime_type.to_s.inspect}, disposition: 'inline', filename: #{table.model.name}.model_name.human.gsub(/[^a-z0-9]/i, '_') + '.#{self.file_extension}')\n" return code.c end end end end
Version data entries
17 entries across 17 versions & 1 rubygems