Sha256: b71af5037cb6aced8a0965a0b84359e2f08e354b53ce8f285f67e6f51933adba
Contents?: true
Size: 709 Bytes
Versions: 2
Compression:
Stored size: 709 Bytes
Contents
# coding: utf-8 require 'csv' module ActiveExport class Csv < ::ActiveExport::Base def export(data) CSV.generate(csv_options) do |csv| csv << generate_header if header? export_data(data, csv) end end def export_file(data, filename) File.atomic_write(filename.to_s) do |file| CSV.open(file, "wb", csv_options) do |csv| csv << generate_header if header? export_data(data, csv) end end filename end protected def csv_options self.config.default_csv_options.merge( self.options[:csv_options] || {} ) end def header? { header: true }.merge(self.options)[:header] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
active_export-0.4.0 | lib/active_export/csv.rb |
active_export-0.3.0 | lib/active_export/csv.rb |