diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2010-08-19 11:06:53 -0500 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2010-08-19 11:07:09 -0500 |
commit | d3e30a18b286b1de93fb484170ab6e1723e364a6 (patch) | |
tree | ebb475c600793706ae96260e601f648f169a6f6e /activerecord | |
parent | 072cd60379dfee830845f32cb81019584d619331 (diff) | |
download | rails-d3e30a18b286b1de93fb484170ab6e1723e364a6.tar.gz rails-d3e30a18b286b1de93fb484170ab6e1723e364a6.tar.bz2 rails-d3e30a18b286b1de93fb484170ab6e1723e364a6.zip |
Memoize STI class lookups for the duration of a request
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/base.rb | 4 | ||||
-rw-r--r-- | activerecord/test/cases/base_test.rb | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 9d3ee9528a..d9b4cd3831 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1171,7 +1171,7 @@ MSG if type_name.match(/^::/) # If the type is prefixed with a scope operator then we assume that # the type_name is an absolute reference. - type_name.constantize + ActiveSupport::Dependencies.constantize(type_name) else # Build a list of candidates to search for candidates = [] @@ -1180,7 +1180,7 @@ MSG candidates.each do |candidate| begin - constant = candidate.constantize + constant = ActiveSupport::Dependencies.constantize(candidate) return constant if candidate == constant.to_s rescue NameError => e # We don't want to swallow NoMethodError < NameError errors diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index b2799f649a..55f0b1ce21 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -1409,7 +1409,7 @@ class BasicsTest < ActiveRecord::TestCase end def test_compute_type_no_method_error - String.any_instance.stubs(:constantize).raises(NoMethodError) + ActiveSupport::Dependencies.stubs(:constantize).raises(NoMethodError) assert_raises NoMethodError do ActiveRecord::Base.send :compute_type, 'InvalidModel' end |