lib/apricoteatsgorilla.rb in smacks-apricoteatsgorilla-0.3.91 vs lib/apricoteatsgorilla.rb in smacks-apricoteatsgorilla-0.4.0

- old
+ new

@@ -227,27 +227,27 @@ # # * +name+ - A Hash key to translate into an XML String. # * +item+ - A Hash value to translate into an XML String. def nested_data_to_xml(name, item) case item - when String, Symbol - tag(name) { item.to_s } when Array item.map { |subitem| nested_data_to_xml(name, subitem) }.join when Hash tag(name) do opt_order(item).map { |tag, value| case value - when String, Symbol - tag(tag) { value.to_s } when Array value.map { |subitem| nested_data_to_xml(tag, subitem) }.join when Hash nested_data_to_xml(tag, value) + else + tag(tag) { value.to_s } if item.respond_to? :to_s end }.join end + else + tag(name) { item.to_s } if item.respond_to? :to_s end end # Creates an XML tag. Expects a block for tag content. Defaults to an empty # element tag in case no block was supplied. @@ -291,10 +291,10 @@ end # Returns a sorted version of a given +hash+ if :sort_keys was enabled. def opt_order(hash) return hash unless sort_keys - hash.sort_by { |kv| kv.first } + hash.keys.sort_by { |s| s.to_s }.map { |key| [key, hash[key]] } end end end \ No newline at end of file