class Exportable::ExportMethods::CsvExporter::Exporter
Public Class Methods
new(model)
click to toggle source
# File lib/exportable/export_methods/csv_exporter.rb, line 18 def initialize(model) @model = model end
Public Instance Methods
export(options)
click to toggle source
# File lib/exportable/export_methods/csv_exporter.rb, line 22 def export(options) CSV.generate do |csv| csv << options[:fields].map(&:to_s) if options[:header] @model.where(nil).find_each do |record| csv << options[:fields].map { |attr| record.send(attr).to_s } end end end