Class: Para::Exporter::Csv

Inherits:
Base
  • Object
show all
Defined in:
lib/para/exporter/csv.rb

Instance Attribute Summary

Attributes inherited from Base

#resources

Instance Method Summary collapse

Methods inherited from Base

#disposition, exports, #file_name, #initialize, #model, register_base_exporter

Constructor Details

This class inherits a constructor from Para::Exporter::Base

Instance Method Details

#export_typeObject



16
17
18
# File 'lib/para/exporter/csv.rb', line 16

def export_type
  :excel
end

#extensionObject



8
9
10
# File 'lib/para/exporter/csv.rb', line 8

def extension
  'csv'
end

#mime_typeObject



12
13
14
# File 'lib/para/exporter/csv.rb', line 12

def mime_type
  'text/csv'
end

#renderObject



20
21
22
23
24
25
26
27
28
# File 'lib/para/exporter/csv.rb', line 20

def render
  CSV.generate do |csv|
    csv << headers

    resources.each do |resource|
      csv << row_for(resource)
    end
  end
end