# Re: Live to\_s calls for rexml attribute

**URL:** <https://www.ruby-forum.com/t/re-live-to-s-calls-for-rexml-attribute/68325>\
**Category:** Ruby\
**Created:** [September 11, 2006, 7:14pm UTC](https://www.ruby-forum.com/t/re-live-to-s-calls-for-rexml-attribute/68325 "2006-09-11T19:14:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![phrogz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@phrogz](https://www.ruby-forum.com/u/phrogz)\
**Post date:** [September 11, 2006, 7:14pm UTC](https://www.ruby-forum.com/t/re-live-to-s-calls-for-rexml-attribute/68325/1 "2006-09-11T19:14:45Z")

</div>

> Another would be to subclass REXML::Element, find all the existing  
> methods where the to\_s is invoked on attributes, and override those  
> methods to delay the evaluation.

FWIW, I found that the above doesn’t work, since REXML::Element uses  
REXML::Attribute to store each attribute, so I can’t subclass that and  
have the rest of REXML use it.

Since it’s only a two-line modification (though it requires copying 40  
lines of source code from REXML), I’ve now decided to include a patch to  
REXML as part of my library.

Still hoping someone out there has a more elegant solution, though.

(I’ve also filed an REXML enhancement request, so maybe 3.1.5 will  
include it and make my patch unnecessary.)
