That sounds like a problem with the use of `to_s`, then, rather than a reason to contort this code substantially in order to work around decisions elsewhere.  You should probably file a ticket to get that changed, and remove this work-around.