From b9a93916f538bfab57815a1d48740c826715ca5d Mon Sep 17 00:00:00 2001 From: Michael Herold Date: Thu, 22 Oct 2020 21:00:11 -0500 Subject: Expose `IndifferentAccess` conversion internally In some cases --- like writing meta-extensions of `IndifferentAccess` --- we need access to the ability to convert a key for the purposes of `IndifferentAccess`. Exposing this behavior as a module function makes this possible. --- lib/hashie/extensions/indifferent_access.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/hashie/extensions/indifferent_access.rb b/lib/hashie/extensions/indifferent_access.rb index d6b9da3..2ff5f28 100644 --- a/lib/hashie/extensions/indifferent_access.rb +++ b/lib/hashie/extensions/indifferent_access.rb @@ -25,6 +25,11 @@ module Hashie module IndifferentAccess include Hashie::Extensions::RubyVersionCheck + # @api private + def self.convert_key(key) + key.to_s + end + def self.included(base) Hashie::Extensions::Dash::IndifferentAccess.maybe_extend(base) @@ -68,7 +73,7 @@ module Hashie end def convert_key(key) - key.to_s + IndifferentAccess.convert_key(key) end # Iterates through the keys and values, reconverting them to -- cgit v1.2.1