From: jean.boussier@... Date: 2020-12-28T11:22:03+00:00 Subject: [ruby-core:101772] [Ruby master Feature#17472] HashWithIndifferentAccess like Hash extension Issue #17472 has been updated by byroot (Jean Boussier). > A feature to implement Rails's ActiveSupport::HashWithIndifferentAccess Would it be possible to have a "hook" akin to `convert_key`? e.g. something like: ``` hash = {} hash.coerce_key = ->(key) { key.is_a?(Symbol) ? key.name : key } ``` ---------------------------------------- Feature #17472: HashWithIndifferentAccess like Hash extension https://bugs.ruby-lang.org/issues/17472#change-89600 * Author: naruse (Yui NARUSE) * Status: Open * Priority: Normal * Target version: 3.1 ---------------------------------------- Rails has [ActiveSupport::HashWithIndifferentAccess](https://api.rubyonrails.org/classes/ActiveSupport/HashWithIndifferentAccess.html), which is widely used in Rails to handle Request, Session, ActionView's form construction, ActiveRecord's DB communication, and so on. It receives String or Symbol and normalize them to fetch the value. But it is implemented with Ruby. If we provide C implementation of that, Rails will gain the performance improvement. summary of previous discussion: https://github.com/rails/rails/pull/40182#issuecomment-687607812 -- https://bugs.ruby-lang.org/ Unsubscribe: