diff options
author | Matthew Draper <matthew@trebex.net> | 2014-08-18 00:04:46 +0930 |
---|---|---|
committer | Matthew Draper <matthew@trebex.net> | 2014-08-18 00:04:46 +0930 |
commit | 898bdc5c541d6c716a9be4dc7625d004f2e59c0c (patch) | |
tree | 162639e3710e0fcbb3e53a96b23a9bdbbd3f3740 /activesupport | |
parent | a08ca4a846ac5fb7b3fbd1e53ea3df2daa01fd8c (diff) | |
parent | 7a41295734e2a2332dc09db08f08eda36f927ca3 (diff) | |
download | rails-898bdc5c541d6c716a9be4dc7625d004f2e59c0c.tar.gz rails-898bdc5c541d6c716a9be4dc7625d004f2e59c0c.tar.bz2 rails-898bdc5c541d6c716a9be4dc7625d004f2e59c0c.zip |
Merge pull request #16338 from robin850/rbx-safe-constantize
Avoid relying on error messages when rescuing
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/inflector/methods.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/inflector/methods.rb b/activesupport/lib/active_support/inflector/methods.rb index 18ba79a8f9..53022de549 100644 --- a/activesupport/lib/active_support/inflector/methods.rb +++ b/activesupport/lib/active_support/inflector/methods.rb @@ -303,8 +303,8 @@ module ActiveSupport def safe_constantize(camel_cased_word) constantize(camel_cased_word) rescue NameError => e - raise unless e.message =~ /(uninitialized constant|wrong constant name) #{const_regexp(camel_cased_word)}$/ || - e.name.to_s == camel_cased_word.to_s + raise if e.name && !(camel_cased_word.to_s.split("::").include?(e.name.to_s) || + e.name.to_s == camel_cased_word.to_s) rescue ArgumentError => e raise unless e.message =~ /not missing constant #{const_regexp(camel_cased_word)}\!$/ end |