Sha256: c4d7ecf265a67335418b0d944237c6c5d435d7fc85d22bc73eec013700f1a111
Contents?: true
Size: 782 Bytes
Versions: 1
Compression:
Stored size: 782 Bytes
Contents
require 'builder' require 'active_support/inflector' module Leap module XmlSerializer def to_xml(options = {}) options[:indent] ||= 2 xml = options[:builder] ||= Builder::XmlMarkup.new(options) xml.instruct! unless options[:skip_instruct] yield xml xml end def array_to_xml(xml, name, array, singular_name = name.to_s.singularize) xml.__send__ name, :type => 'array' do |subblock| array.each do |item| if item.is_a? Symbol or !item.respond_to?(:to_xml) item = item.to_s if item.is_a?(Symbol) subblock.__send__ singular_name, item, :type => 'string' else item.to_xml(:builder => subblock, :skip_instruct => true) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
leap-0.4.6 | lib/leap/xml_serializer.rb |