Closed esad closed 13 years ago
Btw. the use-case with string keys came up while using a simple yml file with string keys (which is yaml "default"). I'll see that I extend the tests to cover this.
Ok, I see. In my own uses I've always used Ambry to create the "database," and then saved it to YAML; I never edit the YAML directly. So I think since you're editing the YAML by hand you're seeing issues I hadn't seen yet. But obviously a lot of people are going to want to hand-edit the YAML (it's sort of the whole point of supporting YAML in addition to Marshal), so Ambry definitely needs to make this work smoothly.
I would prefer to avoid depending on Active Support; I think it would be best to just make sure that any assignment of a key/value pair to @attributes
invokes #to_sym
on the key first. Again, since that hash is managed internally it should be no problem. In a worst case scenario, we can just create our own symbolize keys method rather than demand AS and all its dependencies, since it's just a 1-3 liner.
Actually, looking this over again I think your original idea was right. It's easier and more flexible to just allow the keys to be strings. I pulled your original patch and added a few more changes to try to make sure this works consistently, let me know if it's working for you on your side.
Yes, you're right. Should we depend on ActiveSupport for
Hash#symbolize_keys
?