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) " datasource = GoogleDataSource::DataSource::Base.from_params(params)\n \#{template.source.dup}\n if !datasource.reporting.nil? && datasource.reporting.has_form?\n datasource.callback = \"$('\\\\\\#\\\#{datasource.reporting.form_id}').html(\\\#{render(:partial => datasource.reporting.partial).to_json});\"\n end\n\n if datasource.format == 'csv'\n headers['Content-Type'] = 'text/csv; charset=utf-8'\n headers['Content-Disposition'] = \"attachment; filename=\\\\\"\\\#{datasource.export_filename}.csv\\\\\"\"\n end\n\n if datasource.format == 'xml'\n headers['Content-Type'] = 'application/xml; charset=utf-8'\n headers['Content-Disposition'] = \"attachment; filename=\\\\\"\\\#{datasource.export_filename}.xml\\\\\"\"\n end\n\n datasource.response\n EOT\nend\n" |