class Exportable::ExportMethods::XmlExporter::Exporter
Exporter
class for XML
Public Class Methods
new(model)
click to toggle source
# File lib/exportable/export_methods/xml_exporter.rb, line 17 def initialize(model) @model = model end
Public Instance Methods
export(options)
click to toggle source
# File lib/exportable/export_methods/xml_exporter.rb, line 21 def export(options) Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml| xml.root do xml.send(@model.model_name.collection) do @model.all.find_each do |record| xml.send(@model.model_name.element) do options[:fields].each do |attr| xml.send(attr, record.send(attr).to_s) end end end end end end.to_xml end