Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

HashWithIndifferentAccess should override #store

#5775

params[:save_me]=x and params['save_me']=x are equivalent.

params.store(:save_me, x) and params.store('save_me', x) are not equivalent.

params.store(:test1, 1)
params.store('test1', 11)
params[:test2] = 2
params['test2'] = 22

Results in:

--- !map:ActiveSupport::HashWithIndifferentAccess
test1: 11
:test1: 1
test2: 22

When I am expecting

--- !map:ActiveSupport::HashWithIndifferentAccess 
test1: 11
test2: 22

Reported by greg (at araelium) · October 9th, 2010 @ 05:41 PM

State: resolved
Milestone: 3.0.2
Assigned to: Santiago Pastorino Santiago Pastorino
Importance: Low

Activity

  1. Santiago Pastorino
    Santiago Pastorino
    • Importance changed from to Low

    Can you provide a patch with a test case? or a test case only?.
    Thank you.

    October 9th, 2010 @ 06:16 PM

  2. Andrea Campi
    Andrea Campi
    • Tag changed from activesupport, hashwithindifferentaccess, params to activesupport, hashwithindifferentaccess, params, patched

    There you go.
    I implemented #store the same as #[]= but maybe one should be an alias to the other?
    Would anybody ever subclass HashWithIndifferentAccess and override just one of #[]= and #store?

    October 9th, 2010 @ 06:34 PM

  3. Álvaro Bautista
    Álvaro Bautista
    • Tag changed from activesupport, hashwithindifferentaccess, params, patched to activesupport, hashwithindifferentaccess, params

    I agree, since fetch is already overridden.

    It may not be needed, as it is quite straightforward, but I attach a patch for it anyway.

    October 9th, 2010 @ 06:54 PM

  4. Álvaro Bautista
    Álvaro Bautista

    My patch was, in fact, not needed.

    I'm sorry, I should have refreshed the ticket page before submitting.

    October 9th, 2010 @ 07:00 PM

  5. Andrea Campi
    Andrea Campi
    • Tag changed from activesupport, hashwithindifferentaccess, params to activesupport, hashwithindifferentaccess, patch

    October 9th, 2010 @ 07:39 PM

  6. Andrea Campi
  7. greg (at araelium)
  8. Santiago Pastorino
    Santiago Pastorino
    • State changed from new to open
    • Milestone cleared.
    • Assigned user set to Santiago Pastorino

    An alias is the preferred way to go here ;)

    October 9th, 2010 @ 10:16 PM

  9. Andrea Campi
    Andrea Campi

    Thought so :) There you go.

    October 9th, 2010 @ 11:11 PM

  10. Repository
  11. Repository
  12. Jeremy Kemper
  13. Ryan Bigg
    Ryan Bigg
    • Tag changed from sheepskin boots, activesupport, hashwithindifferentaccess, patch to activesupport hashwithindifferentaccess patch

    Automatic cleanup of spam.

    October 16th, 2010 @ 02:22 AM