Class: Hotwire::Response::Csv
- Defined in:
- lib/hotwire/response/csv.rb
Overview
Specialization responsible for producing responses in CSV format.
Instance Attribute Summary
Attributes inherited from Base
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#add_column, #add_columns, #initialize, #set_data
Methods inherited from Base
#add_error, #initialize, #valid?, #validate
Constructor Details
This class inherits a constructor from Hotwire::Response::Base
Instance Method Details
#body ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/hotwire/response/csv.rb', line 5 def body rsp = [] CSV::Writer.generate(rsp) do |csv| csv << columns.map { |col| col[:label] || col[:id] || col[:type] } data.each do |datarow| csv << datarow end end return rsp.join end |