-
Notifications
You must be signed in to change notification settings - Fork 57
Description
The xml method does not behave as I would expect as it modifies the hash that is passed into it. Moreover, it modifies elements within the hash as it proceeds. Consider the following code:
nil_content = { :content! => nil, :'@xs1:nil' => 1 }
bar = { request: { "attributes" => { "text" => nil_content, "date" => nil_content } }}
bar_xml = Gyoku.xml(bar)
puts bar_xml
This produces:
Note that the xs1:nil attribute is not set in the XML when it should be. This is because somehow Gyoku is modifying the content of the nil_content variable.
By changing the bar_xml assignment to use the Rails deep_dup() Hash method to:
bar_xml = Gyoku.xml(bar.deep_dup)
puts bar_xml
This produces:
I note that in the implementation it performs a dup on the hash that is called, but that is insufficient. It should perform (the equivalent) a deep_dup instead.