class Decisive::TemplateHandler
Public Class Methods
call(template, source=template.source)
click to toggle source
# File lib/decisive/template_handler.rb, line 12 def self.call template, source=template.source <<~RUBY extend Decisive::DSL context = (#{source}) response.headers["Content-Transfer-Encoding"] = "binary" response.headers["Content-Disposition"] = %(attachment; filename="\#{context.filename}") if context.csv? response.headers["Content-Type"] = "text/csv" if controller.is_a?(ActionController::Live) begin context.each do |row| response.stream.write row.to_csv(force_quotes: true) end ensure response.stream.close end "" else context.to_csv(force_quotes: true) end else response.headers["Content-Type"] = "application/vnd.ms-excel" context.to_xls end RUBY end
register()
click to toggle source
# File lib/decisive/template_handler.rb, line 8 def self.register ActionView::Template.register_template_handler 'decisive', self end