On 4/20/05, Adam Sanderson
<netghost-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Now it''s quite debatable whether I should use an array as a key,
but lets
> just say it''s acceptable, I wanted to make sure this was the
expected
> behavior, and would keep on doing this in future versions.
This is not the expected behavior.
> Should I file things like this as bug reports? If so I won''t
bother the
> mailing list with these kinds of oddities any more ;)
I''ve taken care of filing a bug report. I''ll include a brief
description here:
The issue is caused by an errant call of Hash#stringify_keys. When an
indifferent hash is created, all keys are converted to strings. This
is done as shown below, taken from
activesupport/lib/active_support/core_ext/hash/indifferent_access.rb:
def initialize(constructor = {})
if constructor.is_a?(Hash)
super()
update(constructor.stringify_keys)
else
super(constructor)
end
end
The call to stringify_keys ought to be removed.
update(constructor)
Will perform provide the desired effect.
I might add that HashWithIndifferentAccess#with_indifferent_access
ought to return self.