aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorclaudiob <claudiob@inventati.org>2016-10-21 22:48:14 -0700
committerclaudiob <claudiob@inventati.org>2016-10-21 22:55:51 -0700
commitfbda46758bdf4b356df468d92f86111b779265cf (patch)
tree56470681d9455d8d8e3ebfd77d923e07dd550498
parent8447f8d01c3722593ccd345fd7e88be8039ecbf1 (diff)
downloadrails-fbda46758bdf4b356df468d92f86111b779265cf.tar.gz
rails-fbda46758bdf4b356df468d92f86111b779265cf.tar.bz2
rails-fbda46758bdf4b356df468d92f86111b779265cf.zip
Revert #26826 and add documentation
This reverts commit a01cf703 as explained in the comment to #26826: Realized that this PR caused the following warning in Travis CI: ``` /home/travis/build/rails/rails/activesupport/lib/active_support/dependencies.rb:293: warning: loading in progress, circular require considered harmful - /home/travis/build/rails/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb ``` Indeed, `active_support/core_ext/hash/indifferent_access.rb` **needs** to require `active_support/hash_with_indifferent_access.rb` in order to access the class `ActiveSupport::HashWithIndifferentAccess`. The other way around, though, is not _strictly_ required, unless someone tries (like I did in the [gist above](https://gist.github.com/claudiob/43cc7fe77ff95951538af2825a71e5ec)) to use `ActiveSupport::HashWithIndifferentAccess` by only requiring `active_support/hash_with_indifferent_access.rb` without first requiring `active_support/core_ext/hash/indifferent_access.rb`. I think the solution to this is to revert this PR and instead change the documentation to explicitly state that **developers should not require 'active_support/hash_with_indifferent_access'** if all they want is to use `ActiveSupport::HashWithIndifferentAccess` – instead they should require `active_support/core_ext/hash/indifferent_access.rb`.
-rw-r--r--activesupport/lib/active_support/hash_with_indifferent_access.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/hash_with_indifferent_access.rb b/activesupport/lib/active_support/hash_with_indifferent_access.rb
index a56943d99d..7ecc5c19bd 100644
--- a/activesupport/lib/active_support/hash_with_indifferent_access.rb
+++ b/activesupport/lib/active_support/hash_with_indifferent_access.rb
@@ -1,6 +1,5 @@
require "active_support/core_ext/hash/keys"
require "active_support/core_ext/hash/reverse_merge"
-require "active_support/core_ext/hash/indifferent_access"
module ActiveSupport
# Implements a hash where keys <tt>:foo</tt> and <tt>"foo"</tt> are considered
@@ -41,6 +40,12 @@ module ActiveSupport
# rgb = { black: '#000000', white: '#FFFFFF' }.with_indifferent_access
#
# which may be handy.
+ #
+ # To access this class outside of Rails, require the core extension with:
+ #
+ # require "active_support/core_ext/hash/indifferent_access"
+ #
+ # which will, in turn, require this file.
class HashWithIndifferentAccess < Hash
# Returns +true+ so that <tt>Array#extract_options!</tt> finds members of
# this class.