From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-2.6 required=3.0 tests=AWL,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY shortcircuit=no autolearn=no autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 52D461F4B4 for ; Mon, 28 Dec 2020 11:22:20 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 76354120A1B; Mon, 28 Dec 2020 20:21:25 +0900 (JST) Received: from xtrwkhkc.outbound-mail.sendgrid.net (xtrwkhkc.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id 5BD70120A09 for ; Mon, 28 Dec 2020 20:21:23 +0900 (JST) Received: by filterdrecv-p3mdw1-7474cd8bfd-d66mf with SMTP id filterdrecv-p3mdw1-7474cd8bfd-d66mf-19-5FE9BFDB-25 2020-12-28 11:22:03.875617416 +0000 UTC m=+1513180.899815166 Received: from herokuapp.com (unknown) by ismtpd0125p1mdw1.sendgrid.net (SG) with ESMTP id HFRQua3KQPWG-pHBweLQVw for ; Mon, 28 Dec 2020 11:22:03.822 +0000 (UTC) Date: Mon, 28 Dec 2020 11:22:03 +0000 (UTC) From: jean.boussier@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 77674 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Feature X-Redmine-Issue-Id: 17472 X-Redmine-Issue-Author: naruse X-Redmine-Sender: byroot X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: =?us-ascii?Q?AchqQMoUBMcQgz7gop0XiYUiatGIY7E61JGsTL4Fvjf9HNsdE3phsIkokk4c6w?= =?us-ascii?Q?ciVytfoQgg0YzY5v3u92rCf3Bn7qu=2Fgck51xqwJ?= =?us-ascii?Q?e7CwAi6zBPcjHRlfrZ8WgyG2E+7WX1iGtlBKVPi?= =?us-ascii?Q?RIHHTs13P6hpHWYm3OQq1yDiZZVD79ZpeBuTPVk?= =?us-ascii?Q?9mNQcquOtxPzdGHt6Ojoyk5GHaoxCuKHAthTi60?= =?us-ascii?Q?hKI51smMCQqMSp9Qg=3D?= To: ruby-core@ruby-lang.org X-Entity-ID: b/2+PoftWZ6GuOu3b0IycA== X-ML-Name: ruby-core X-Mail-Count: 101772 Subject: [ruby-core:101772] [Ruby master Feature#17472] HashWithIndifferentAccess like Hash extension X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" 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/