Permalink
Browse files

let Ruby do the is_a check for us

  • Loading branch information...
1 parent 10b538c commit 6062e42f982e0641de023419dc357bf1ec6b5e35 @tenderlove tenderlove committed May 16, 2013
Showing with 4 additions and 3 deletions.
  1. +4 −3 activerecord/lib/active_record/inheritance.rb
@@ -116,9 +116,10 @@ def compute_type(type_name)
begin
constant = ActiveSupport::Dependencies.constantize(candidate)
return constant if candidate == constant.to_s
- rescue NameError => e
- # We don't want to swallow NoMethodError < NameError errors
- raise e unless e.instance_of?(NameError)
+ # We don't want to swallow NoMethodError < NameError errors
+ rescue NoMethodError
+ raise
+ rescue NameError
end
end

1 comment on commit 6062e42

@Empact
Contributor
Empact commented on 6062e42 May 17, 2013

This is a fine refactoring, but this error-swallowing should be significantly narrower - currently it's swallowing NameErrors unrelated to the lookup. See #8298.

Please sign in to comment.