Method: Csb::Handler.call

Defined in:
lib/csb/handler.rb

.call(template, source = nil) ⇒ Object



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

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

  "    csv = ::Csb::Template.new(\n      utf8_bom: ::Csb.configuration.utf8_bom,\n      streaming: ::Csb.configuration.streaming,\n    )\n    \#{source}\n    controller.send(:send_file_headers!, type: 'text/csv', filename: csv.filename)\n    if csv.streaming?\n      response.headers['Cache-Control'] = 'no-cache'\n      response.headers['X-Accel-Buffering'] = 'no'\n      # SEE: https://github.com/rack/rack/issues/1619\n      if Gem::Version.new('2.2.0') <= Gem::Version.new(Rack::RELEASE)\n        response.headers['Last-Modified'] = '0'\n      end\n    end\n    csv.build\n  RUBY\nend\n"