maik / xml-simple

Easy API for working with XML documents
MIT License
88 stars 27 forks source link

is_a? instead of instance_of? #3

Closed hozumi closed 13 years ago

hozumi commented 13 years ago

Hi,

Current XmlSimple use instance_of? to check class in every point. I prefer is_a? to instance_of?, because is_a? returns true with subclass of target class. The instance_of? returns true with only target class. This limitation often require conversion from subclass of Hash into Hash. For example, Mongoid use BSON::OrderedHash, which inherit Hash, to represent hash of models. So conversion is required when using XmlSimple#xml_out. What do you think?

Thanks.

maik commented 13 years ago

Hi Takahiro!

Current XmlSimple use instance_of? to check class in every point. I prefer is_a? to instance_of?, because is_a? returns true with subclass of target class. The instance_of? returns true with only target class. This limitation often require conversion from subclass of Hash into Hash. For example, Mongoid use BSON::OrderedHash, which inherit Hash, to represent hash of models. So conversion is required when using XmlSimple#xml_out. What do you think? You are right and I have replaced instance_of? with is_a?.

Thank you very much!

Best, Maik

hozumi commented 13 years ago

Maik Thank you very much too!