Method: Sequel::Plugins::CsvSerializer::InstanceMethods#to_csv
- Defined in:
- lib/sequel/plugins/csv_serializer.rb
#to_csv(opts = OPTS) ⇒ Object
Return a string in CSV format. Accepts the same options as CSV.new, as well as the following options:
- :except
-
Symbol or Array of Symbols of columns not to include in the CSV output.
- :only
-
Symbol or Array of Symbols of columns to include in the CSV output, ignoring all other columns
- :include
-
Symbol or Array of Symbols specifying non-column attributes to include in the CSV output.
164 165 166 167 168 169 170 171 |
# File 'lib/sequel/plugins/csv_serializer.rb', line 164 def to_csv(opts = OPTS) opts = model.process_csv_serializer_opts(opts) headers = opts[:headers] CsvSerializer.csv_call(:generate, model.process_csv_serializer_opts(opts)) do |csv| csv << headers.map{|k| public_send(k)} end end |