module Sequel::Plugins::CsvSerializer::InstanceMethods
Public Instance Methods
Source
# File lib/sequel/plugins/csv_serializer.rb 138 def from_csv(csv, opts = OPTS) 139 row = CSV.parse_line(csv, **model.process_csv_serializer_opts(opts)).to_hash 140 row.delete(nil) 141 set(row) 142 end
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 153 def to_csv(opts = OPTS) 154 opts = model.process_csv_serializer_opts(opts) 155 headers = opts[:headers] 156 157 CSV.generate(**model.process_csv_serializer_opts(opts)) do |csv| 158 csv << headers.map{|k| public_send(k)} 159 end 160 end
Return a string in CSV format. Accepts the same options as CSV.new, as well as the following options: