aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/inflector/methods.rb
diff options
context:
space:
mode:
authorAkira Matsuda <ronnie@dio.jp>2013-01-05 14:45:18 +0900
committerAkira Matsuda <ronnie@dio.jp>2013-01-06 15:41:14 +0900
commit70ae89c321444eef42c0c011b522f926250e7acd (patch)
tree0f7abe41af87a17deb5c90465d1e9a190e4a70a9 /activesupport/lib/active_support/inflector/methods.rb
parent3e8134a750bee5c4f7ede67f33263d36e4ff1474 (diff)
downloadrails-70ae89c321444eef42c0c011b522f926250e7acd.tar.gz
rails-70ae89c321444eef42c0c011b522f926250e7acd.tar.bz2
rails-70ae89c321444eef42c0c011b522f926250e7acd.zip
Remove unnecessary begin..rescue..end, use only rescue
Diffstat (limited to 'activesupport/lib/active_support/inflector/methods.rb')
-rw-r--r--activesupport/lib/active_support/inflector/methods.rb14
1 files changed, 6 insertions, 8 deletions
diff --git a/activesupport/lib/active_support/inflector/methods.rb b/activesupport/lib/active_support/inflector/methods.rb
index 1eb2b4212b..39648727fd 100644
--- a/activesupport/lib/active_support/inflector/methods.rb
+++ b/activesupport/lib/active_support/inflector/methods.rb
@@ -266,14 +266,12 @@ module ActiveSupport
# 'UnknownModule'.safe_constantize # => nil
# 'UnknownModule::Foo::Bar'.safe_constantize # => nil
def safe_constantize(camel_cased_word)
- begin
- 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
- rescue ArgumentError => e
- raise unless e.message =~ /not missing constant #{const_regexp(camel_cased_word)}\!$/
- end
+ 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
+ rescue ArgumentError => e
+ raise unless e.message =~ /not missing constant #{const_regexp(camel_cased_word)}\!$/
end
# Returns the suffix that should be added to a number to denote the position