module IletiMerkezi::XmlBuilder
Constants
- XML_TAG
Public Instance Methods
hash_to_xml(hash)
click to toggle source
# File lib/ileti_merkezi/utils/xml_builder.rb, line 8 def hash_to_xml(hash) hash.each_with_object([]) do |(key, value), tags| tags << case value when Hash then create_xml_tag(key, hash_to_xml(value)) when Array then array_to_xml(key, value) else create_xml_tag(key, value) end end.flatten.join end
Private Instance Methods
array_to_xml(tag, collection)
click to toggle source
# File lib/ileti_merkezi/utils/xml_builder.rb, line 21 def array_to_xml(tag, collection) collection.map do |item| create_xml_tag( tag, (item.is_a?(Hash) ? hash_to_xml(item) : item) ) end end
create_xml_tag(tag, content)
click to toggle source
# File lib/ileti_merkezi/utils/xml_builder.rb, line 29 def create_xml_tag(tag, content) format(XML_TAG, tag: tag, content: content) end