From: lamont@... Date: 2021-04-02T19:34:26+00:00 Subject: [ruby-core:103189] [Ruby master Feature#17472] HashWithIndifferentAccess like Hash extension Issue #17472 has been updated by lamont (Lamont Granquist). Any implementation should probably consider recursive structures under arrays and all the mutator methods on Array: ``` ruby % pry [1] pry(main)> require 'active_support/hash_with_indifferent_access' => true [2] pry(main)> test = ActiveSupport::HashWithIndifferentAccess.new => {} [3] pry(main)> test['foo'] = [] => [] [4] pry(main)> test['foo'] << { bar: "baz" } => [{:bar=>"baz"}] [5] pry(main)> test.class => ActiveSupport::HashWithIndifferentAccess [6] pry(main)> test['foo'][0].class => Hash [7] pry(main)> test['foo'] = [ { bar: "baz" } ] NoMethodError: undefined method `nested_under_indifferent_access' for {:bar=>"baz"}:Hash from /Users/lamont/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.3.1/lib/active_support/hash_with_indifferent_access.rb:381:in `convert_value' [8] pry(main)> ``` ---------------------------------------- Feature #17472: HashWithIndifferentAccess like Hash extension https://bugs.ruby-lang.org/issues/17472#change-91264 * 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: