Return a CSV string representing an array of all objects in this dataset.
Takes the same options as the instance method, and passes them to every
instance. Accepts the same options as CSV.new, as well as the following
options:
:array : | An array of instances. If this is not provided, calls all on the receiver
to get the array.
|
[Source]
164: def to_csv(opts = OPTS)
165: opts = model.process_csv_serializer_opts({:columns=>columns}.merge!(opts))
166: items = opts.delete(:array) || self
167:
168: CSV.generate(opts) do |csv|
169: items.each do |object|
170: csv << opts[:headers].map{|header| object.public_send(header) }
171: end
172: end
173: end