Class: Kugiru::Handler

Inherits:
Object
  • Object
show all
Defined in:
lib/kugiru/handler.rb

Class Method Summary collapse

Class Method Details

.call(template, source = nil) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/kugiru/handler.rb', line 8

def self.call(template, source = nil)
  source ||= template.source

  "    csv = OpenStruct.new(\n      utf8_bom: ::Kugiru.configuration.utf8_bom,\n      streaming: ::Kugiru.configuration.streaming,\n      cols: {},\n      data: []\n    )\n    \#{source}\n    controller.send(:send_file_headers!, type: 'text/csv', filename: csv.filename)\n    _builder_args = csv.to_h.slice(:utf8_bom, :cols, :data)\n    if csv.streaming\n      response.headers['Cache-Control'] = 'no-cache'\n      response.headers['X-Accel-Buffering'] = 'no'\n      ::Kugiru::Builder.build_enumerator(_builder_args)\n    else\n      ::Kugiru::Builder.build(_builder_args)\n    end\n  RUBY\nend\n"