Module | Sequel::Plugins::XmlSerializer::DatasetMethods |
In: |
lib/sequel/plugins/xml_serializer.rb
|
Return an XML string containing all model objects specified with this dataset. Takes all of the options available to Model#to_xml, as well as the :array_root_name option for specifying the name of the root node that contains the nodes for all of the instances.
# File lib/sequel/plugins/xml_serializer.rb, line 320 320: def to_xml(opts={}) 321: raise(Sequel::Error, "Dataset#to_xml") unless row_proc 322: x = model.xml_builder(opts) 323: name_proc = model.xml_serialize_name_proc(opts) 324: array = if opts[:array] 325: opts = opts.dup 326: opts.delete(:array) 327: else 328: all 329: end 330: x.send(name_proc[opts.fetch(:array_root_name, model.send(:pluralize, model.send(:underscore, model.name))).to_s]) do |x1| 331: array.each do |obj| 332: obj.to_xml(opts.merge(:builder=>x1)) 333: end 334: end 335: x.to_xml 336: end