Class: GoogleDataSource::DataSource::TemplateHandler
- Inherits:
-
Object
- Object
- GoogleDataSource::DataSource::TemplateHandler
- Defined in:
- lib/google_data_source/template_handler.rb
Overview
A simple template handler for a data source Provides a GoogleDataSource::Base object datasource in the template so the template can fill it with data
Class Method Summary collapse
Class Method Details
.call(template) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/google_data_source/template_handler.rb', line 8 def self.call(template) <<-EOT datasource = GoogleDataSource::DataSource::Base.from_params(params) #{template.source.dup} if !datasource.reporting.nil? && datasource.reporting.has_form? datasource.callback = "$('\\\#\#{datasource.reporting.form_id}').html(\#{render(:partial => datasource.reporting.partial).to_json});" end if datasource.format == 'csv' headers['Content-Type'] = 'text/csv; charset=utf-8' headers['Content-Disposition'] = "attachment; filename=\\"\#{datasource.export_filename}.csv\\"" end if datasource.format == 'xml' headers['Content-Type'] = 'application/xml; charset=utf-8' headers['Content-Disposition'] = "attachment; filename=\\"\#{datasource.export_filename}.xml\\"" end datasource.response EOT end |