Class: GoogleDataSource::DataSource::XmlData

Inherits:
Base
  • Object
show all
Defined in:
lib/google_data_source/xml_data.rb

Instance Attribute Summary

Attributes inherited from Base

#callback, #column_labels, #errors, #export_filename, #formatters, #reporting, #virtual_columns, #xml_class

Instance Method Summary collapse

Methods inherited from Base

#[], #[]=, #add_error, #column_ids, #columns, #columns=, #data, #data=, #format, #formatter, from_gdata_params, from_params, #guess_columns, #has_formatter?, #is_virtual_column?, #required_columns, #set, #set_required_columns, #valid?, #validate, #virtual_column

Instance Method Details

#responseObject

include ActionView::Helpers::NumberHelper



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/google_data_source/xml_data.rb', line 7

def response
  cols = columns.map { |col| col.id || col.type }
  builder = ::Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
    xml.send(xml_class.pluralize, :type => 'array') do
      data.each do |datarow|
        xml.send(xml_class) do
          datarow.zip(cols).each do |val, key|
            xml.send("#{key}", val.is_a?(Hash) ? val[:v] : val)
          end
        end
      end
    end
  end
 
  builder.to_xml
end