crack icon indicating copy to clipboard operation
crack copied to clipboard

Ability to disable monkey-patched @attributes instance variable on Strings

Open mjwillson opened this issue 13 years ago • 0 comments

REXMLUtilityNode seems to set an 'attributes' instance variable on String instances.

While not a show-stopper, this makes YAML serialization quite verbose, eg:

:postal_code: !str 
  str: postal code
  "@attributes": {}

Would be good to avoid doing this if there aren't any attributes, or indeed to have an option to turn off this monkey-patching altogether.

The code here seems to be the culprit:

if @text
  t = typecast_value( unnormalize_xml_entities( inner_html ) )
  t.class.send(:attr_accessor, :attributes)
  t.attributes = attributes
  return { name => t }
else

mjwillson avatar Sep 22 '10 12:09 mjwillson