Mash will cast all Hashes (and subclasses) to Mash on value assign
Reported by Carl Lerche | September 17th, 2008 @ 09:15 AM | in 0.9.8
Check the following bit of code:
class Magic < Hash ; end
(mash = Mash.new)[:magic] = Magic.new
mash[:magic].class == Mash
It seems that Mash is converting everything that it stores to Mashes (for the []= method and co.). It seems to me that values stored in a Mash should ONLY convert Hashes to Mashes on #update, #merge, etc... values stored in a Mash should not be modified.
This actually breaks sessions since any custom class inherited from Hash will get converted to a Mash (and obviously break everything.
Comments and changes to this ticket
-
Michael Klishin (antares) September 17th, 2008 @ 08:17 PM
- → State changed from new to open
- → Milestone changed from to 0.9.8
- → Assigned user changed from to Michael Klishin (antares)
-
Yehuda Katz (wycats) September 19th, 2008 @ 11:34 AM
- → Assigned user changed from Michael Klishin (antares) to Fabien Franzen (loob2)
-

Fabien Franzen (loob2) September 19th, 2008 @ 08:26 PM
- → State changed from open to resolved
I resolved the problem as follows: only pure Hashes (not subclasses of Hashes) will be converted to Mash on assignent.
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
