That may be a shitty title. If anyone has a better idea for how to describe this question, happy to hear it.
If I’m building an XML document with ElementTree in Python, I can do something along the lines of
tag = ET.SubElement(root, 'tag')
tag.set('foo', 'true')
if bar
tag.set('baz', 'false')
But with Builder in Ruby, The only way I can see how to set tag attributes is to do the following:
xml.tag :foo => 'true', :baz => 'false'
Is there a way for me to assign baz later after that point? Or do I have to rewrite the entire thing like so:
if bar
xml.tag :foo => 'true', :baz => 'false'
else
xml.tag :foo => 'true', :baz => 'true'
end
Code is more clear when you don’t update in-place. Why not this?