yoreek / XML-Hash-XS

Convert hash to xml
Other
4 stars 4 forks source link

Check for `to_string` also for object serialization #12

Closed slobo closed 6 years ago

slobo commented 6 years ago

Popular CPAN modules like Mojolicious provides to_string but not toString. Without this change we either have to monkeypatch Mojo::URL to provide toString, or to manually flatten objects before passing to hash2xml.

I haven't tested the change, just opening pull request to see if it's something you would be interested in accepting. I do not know performance impact of change like this, but perhaps it would be nice to also add another popular variation - as_string.

But perhaps ideally, if there is way to detect that class has an overload for q{""}, that should be used instead - is it possible to detect via XS?

Thanks

yoreek commented 6 years ago

Thank you for your interest in the module. I have implemented a variant, that checks if the stringification operator is overloaded. Can you check please?

slobo commented 6 years ago

Works great for our use case, thanks for such a quick response!