diff options
author | Corey Ward <corey.atx@gmail.com> | 2017-01-17 14:59:36 -0600 |
---|---|---|
committer | Corey Ward <corey.atx@gmail.com> | 2017-01-17 22:18:36 -0600 |
commit | 1d3ddac7b8fbc4ff5cdd984f58991cf736748ad9 (patch) | |
tree | aba307e0928cf52fbe18c732f5b272f736bce1b0 /activesupport/lib/active_support | |
parent | a8a673f2e43f27b770ebfc75572ff7de0bbe1f6c (diff) | |
download | rails-1d3ddac7b8fbc4ff5cdd984f58991cf736748ad9.tar.gz rails-1d3ddac7b8fbc4ff5cdd984f58991cf736748ad9.tar.bz2 rails-1d3ddac7b8fbc4ff5cdd984f58991cf736748ad9.zip |
Adjust `Module.parent_name` to work when frozen; fixes #27637
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/core_ext/module/introspection.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/core_ext/module/introspection.rb b/activesupport/lib/active_support/core_ext/module/introspection.rb index 0665aa88bc..ca20a6d4c5 100644 --- a/activesupport/lib/active_support/core_ext/module/introspection.rb +++ b/activesupport/lib/active_support/core_ext/module/introspection.rb @@ -5,10 +5,12 @@ class Module # # M::N.parent_name # => "M" def parent_name - if defined? @parent_name + if defined?(@parent_name) @parent_name else - @parent_name = name =~ /::[^:]+\Z/ ? $`.freeze : nil + parent_name = name =~ /::[^:]+\Z/ ? $`.freeze : nil + @parent_name = parent_name unless frozen? + parent_name end end |