Module: DataBindings::Adapters::XML::Convert
- Includes:
- ConverterHelper, GemRequirement
- Defined in:
- lib/data_bindings/adapters/xml.rb
Overview
Creates a String repsentation of a Ruby Hash or Array.
Class Method Summary collapse
Instance Method Summary collapse
Methods included from ConverterHelper
Methods included from GemRequirement
Class Method Details
.construct(generator, name, obj, builder = nil) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/data_bindings/adapters/xml.rb', line 49 def self.construct(generator, name, obj, builder = nil) root = builder.nil? builder ||= Builder::XmlMarkup.new builder.instruct!(:xml, :encoding => "UTF-8") if root case obj when Array builder.__send__(name || "doc") do |b| obj.each_with_index(o, i) construct(generator, i.to_s, o, b) end when Hash builder.__send__(name || "doc") do |b| obj.each do |k, v| construct(generator, k, v, b) end end else builder.__send__(name, obj) end builder.target! if root end |