diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2017-09-20 13:11:34 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-20 13:11:34 -0600 |
commit | eddb9baf39bce0608b3364339ec171332a315d9f (patch) | |
tree | 1a4055b2bfcd38a8ec9a7b688fb4a7d879ac86db /guides/source | |
parent | e7f39af3fafbb83e93b3bb58a03aefbf10752f41 (diff) | |
parent | 275065355c833b769daf898bf7940c0ff98b6a7c (diff) | |
download | rails-eddb9baf39bce0608b3364339ec171332a315d9f.tar.gz rails-eddb9baf39bce0608b3364339ec171332a315d9f.tar.bz2 rails-eddb9baf39bce0608b3364339ec171332a315d9f.zip |
Merge pull request #30624 from bogdanvlviv/deprecate_Module_reachable
Deprecate `Module#reachable?` method
Diffstat (limited to 'guides/source')
-rw-r--r-- | guides/source/active_support_core_extensions.md | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/guides/source/active_support_core_extensions.md b/guides/source/active_support_core_extensions.md index 1438245f9c..ae573cc77c 100644 --- a/guides/source/active_support_core_extensions.md +++ b/guides/source/active_support_core_extensions.md @@ -674,44 +674,6 @@ M.parents # => [X::Y, X, Object] NOTE: Defined in `active_support/core_ext/module/introspection.rb`. -### Reachable - -A named module is reachable if it is stored in its corresponding constant. It means you can reach the module object via the constant. - -That is what ordinarily happens, if a module is called "M", the `M` constant exists and holds it: - -```ruby -module M -end - -M.reachable? # => true -``` - -But since constants and modules are indeed kind of decoupled, module objects can become unreachable: - -```ruby -module M -end - -orphan = Object.send(:remove_const, :M) - -# The module object is orphan now but it still has a name. -orphan.name # => "M" - -# You cannot reach it via the constant M because it does not even exist. -orphan.reachable? # => false - -# Let's define a module called "M" again. -module M -end - -# The constant M exists now again, and it stores a module -# object called "M", but it is a new instance. -orphan.reachable? # => false -``` - -NOTE: Defined in `active_support/core_ext/module/reachable.rb`. - ### Anonymous A module may or may not have a name: @@ -745,7 +707,6 @@ end m = Object.send(:remove_const, :M) -m.reachable? # => false m.anonymous? # => false ``` |