Sha256: 25f3e51f8cf7abced918144c16ccc91b7ee47c763ad22bfa375c90deaa32d7b9
Contents?: true
Size: 845 Bytes
Versions: 20
Compression:
Stored size: 845 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: #{mime_type.to_s.inspect}, disposition: 'inline', filename: #{table.model.name}.model_name.human.gsub(/[^a-z0-9]/i, '_') + '.#{file_extension}')\n" code.c end end end end
Version data entries
20 entries across 20 versions & 1 rubygems