Class: SaxStream::Internal::XmlBuilder
- Inherits:
-
Object
- Object
- SaxStream::Internal::XmlBuilder
- Defined in:
- lib/sax_stream/internal/xml_builder.rb
Instance Method Summary collapse
- #build_xml_for(object, parent = nil) ⇒ Object
-
#initialize(options = {}) ⇒ XmlBuilder
constructor
A new instance of XmlBuilder.
Constructor Details
#initialize(options = {}) ⇒ XmlBuilder
Returns a new instance of XmlBuilder.
6 7 8 |
# File 'lib/sax_stream/internal/xml_builder.rb', line 6 def initialize( = {}) @encoding = [:encoding] || 'UTF-8' end |
Instance Method Details
#build_xml_for(object, parent = nil) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/sax_stream/internal/xml_builder.rb', line 10 def build_xml_for(object, parent = nil) mappings = object.mappings in_sub_object = has_doc? @doc ||= build_doc base = add_base_element(@doc, parent || @doc, object) object.mappings.each do |mapping| add_mapping(@doc, base, object, mapping) end in_sub_object ? base : @doc.to_xml end |