diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | lib/soap/generator.rb | 20 |
2 files changed, 19 insertions, 7 deletions
@@ -1,3 +1,9 @@ +Sat Sep 2 12:06:35 2006 NAKAMURA, Hiroshi <[email protected]> + + * lib/soap/generator.rb (SOAP::SOAPGenerator#encode_tag): do not dump + XML attribute which value is nil. value "" and nil both were dumped + as 'attr="value"'. [ruby-dev:29395] + Sat Sep 2 12:00:32 2006 NAKAMURA, Hiroshi <[email protected]> * lib/csv.rb (CSV::IOReader#initialize): use String#[](pos, len) diff --git a/lib/soap/generator.rb b/lib/soap/generator.rb index f179555e1d..d0c07b058a 100644 --- a/lib/soap/generator.rb +++ b/lib/soap/generator.rb @@ -156,16 +156,22 @@ public end def encode_tag(elename, attrs = nil) - if !attrs or attrs.empty? + if attrs.nil? or attrs.empty? @buf << "\n#{ @indent }<#{ elename }>" - elsif attrs.size == 1 - key, value = attrs.shift - @buf << %Q[\n#{ @indent }<#{ elename } #{ key }="#{ value }">] + return + end + ary = [] + attrs.each do |key, value| + ary << %Q[#{ key }="#{ value }"] unless value.nil? + end + case ary.size + when 0 + @buf << "\n#{ @indent }<#{ elename }>" + when 1 + @buf << %Q[\n#{ @indent }<#{ elename } #{ ary[0] }>] else @buf << "\n#{ @indent }<#{ elename } " << - attrs.collect { |key, value| - %Q[#{ key }="#{ value }"] - }.join("\n#{ @indent }#{ @indentstr * 2 }") << + ary.join("\n#{ @indent }#{ @indentstr * 2 }") << '>' end end |