Public Instance methods
from_csv(csv, opts = OPTS)
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. |
[show source]
# File lib/sequel/plugins/csv_serializer.rb 149 def from_csv(csv, opts = OPTS) 150 row = CsvSerializer.csv_call(:parse_line, csv, model.process_csv_serializer_opts(opts)).to_hash 151 row.delete(nil) 152 set(row) 153 end
to_csv(opts = OPTS)
Return a string in CSV format. Accepts the same options as CSV.new, as well as the following options:
:except |
|
:only |
|
:include |
|
[show source]
# File lib/sequel/plugins/csv_serializer.rb 164 def to_csv(opts = OPTS) 165 opts = model.process_csv_serializer_opts(opts) 166 headers = opts[:headers] 167 168 CsvSerializer.csv_call(:generate, model.process_csv_serializer_opts(opts)) do |csv| 169 csv << headers.map{|k| public_send(k)} 170 end 171 end