This project is archived and is in readonly mode.
Subclasses of HashWithIndifferentAccess dup the wrong class
-
Steve Richert
Patched, with no tests as it seems pretty straightforward.
-
laserlemon
- Tag changed from duplicate, hashwithindifferentaccess to hashwithindifferentaccess
-
David Trasbo
- State changed from new to incomplete
- Importance changed from to Low
+1, but:
Rule no. 1: Always add tests. This is no exception. :)
And I'd replace
self.class.newwith justclass.new. -
laserlemon
Here's a new patch including tests. I also discovered that HashWithIndifferentAccess duplication doesn't preserve a default value so I resolved that issue as well. Thank you!
-
laserlemon
I should also mention that
class.newisn't valid Ruby, so I stuck withself.class.new. -
David Trasbo
Ah, ok. Silly me, didn't think about that!
Anyways: +1
Patch applies cleanly and tests pass. Please do unify all the commits in the patch, though.
-
laserlemon
Thanks again for the advice. Here's a new, single-commit diff with a message resolving the ticket.
-
ara.t.howard
some people might be interested in this:
i've fought long and hard with HashWithIndiffentAccess and finally broke down and merged it with OrderedHash - Map is the result. it fixes the issue in this thread too.
-
Repository
- State changed from incomplete to resolved
(from [02039e9752bcb214c2ad85859ecf47dcbb892225]) Ensure that HashWithIndifferentAccess duplication preserves class (for sublclasses) and default value [#5724 Subclasses of HashWithIndifferentAccess dup the wrong class state:resolved]
Signed-off-by: Santiago Pastorino santiago@wyeworks.com
https://github.com/rails/rails/commit/02039e9752bcb214c2ad85859ecf4...
