Module Sequel::Plugins::CsvSerializer::InstanceMethods
In: lib/sequel/plugins/csv_serializer.rb

Methods

from_csv   to_csv  

Public Instance methods

Update the object using the data provided in the first line in CSV. Options:

:headers :The headers to use for the CSV line. Use nil for a header to specify the column should be ignored.

[Source]

     # File lib/sequel/plugins/csv_serializer.rb, line 130
130:         def from_csv(csv, opts = {})
131:           row = CSV.parse_line(csv, model.process_csv_serializer_opts(opts)).to_hash
132:           row.delete(nil)
133:           set(row)
134:         end

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.

[Source]

     # File lib/sequel/plugins/csv_serializer.rb, line 145
145:         def to_csv(opts = {})
146:           opts = model.process_csv_serializer_opts(opts)
147: 
148:           CSV.generate(opts) do |csv|
149:             csv << opts[:headers].map{|k| send(k)}
150:           end
151:         end

[Validate]