From e532531939a610c3a1ba4594d325b10a0c9b4546 Mon Sep 17 00:00:00 2001 From: Robin Dupret Date: Mon, 6 Feb 2017 14:27:08 +0100 Subject: Deprecate the top-level `HashWithIndifferentAccess` contant This constant was kept for the sake of backward compatibility; it is still available under `ActiveSupport::HashWithIndifferentAccess`. Furthermore, since Ruby 2.5 (https://bugs.ruby-lang.org/issues/11547) won't support top level constant lookup, people would have to update their code anyway. --- .../lib/active_support/hash_with_indifferent_access.rb | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'activesupport/lib/active_support') diff --git a/activesupport/lib/active_support/hash_with_indifferent_access.rb b/activesupport/lib/active_support/hash_with_indifferent_access.rb index 79e7feaf47..8638667082 100644 --- a/activesupport/lib/active_support/hash_with_indifferent_access.rb +++ b/activesupport/lib/active_support/hash_with_indifferent_access.rb @@ -316,4 +316,20 @@ module ActiveSupport end end -HashWithIndifferentAccess = ActiveSupport::HashWithIndifferentAccess +class HashWithIndifferentAccess < ActiveSupport::HashWithIndifferentAccess + def initialize(*) + ActiveSupport::Deprecation.warn "HashWithIndifferentAccess is deprecated!" \ + "Use ActiveSupport::HashWithIndifferentAccess instead." + super + end + + def self.inherited(*) + ActiveSupport::Deprecation.warn "HashWithIndifferentAccess is deprecated!" \ + "Use ActiveSupport::HashWithIndifferentAccess instead." + super + end + + def encode_with(coder) + coder.represent_object(nil, ActiveSupport::HashWithIndifferentAccess.new(self)) + end +end -- cgit v1.2.3