diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-08-30 15:07:52 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-08-30 15:07:52 -0700 |
commit | 64669c11174162560aa490b57f2f8b0e45620fc7 (patch) | |
tree | 1f1e09d7c93b687cb1ec80ea7875ad4af57ab6fd /activerecord | |
parent | 9b2cce3660dd91215afe9d26fa29c8f69965e9a5 (diff) | |
download | rails-64669c11174162560aa490b57f2f8b0e45620fc7.tar.gz rails-64669c11174162560aa490b57f2f8b0e45620fc7.tar.bz2 rails-64669c11174162560aa490b57f2f8b0e45620fc7.zip |
require a class for cache computations
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/associations/preloader.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/relation/delegation.rb | 4 |
2 files changed, 4 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations/preloader.rb b/activerecord/lib/active_record/associations/preloader.rb index 2317e34bc0..82bf426b22 100644 --- a/activerecord/lib/active_record/associations/preloader.rb +++ b/activerecord/lib/active_record/associations/preloader.rb @@ -85,7 +85,7 @@ module ActiveRecord def initialize(records, associations, preload_scope = nil) @records = Array.wrap(records).compact.uniq @associations = Array.wrap(associations) - @preload_scope = preload_scope || Relation.create(nil, nil) + @preload_scope = preload_scope || Relation.new(nil, nil) end def run diff --git a/activerecord/lib/active_record/relation/delegation.rb b/activerecord/lib/active_record/relation/delegation.rb index 1d87b028ec..dd7d2582a0 100644 --- a/activerecord/lib/active_record/relation/delegation.rb +++ b/activerecord/lib/active_record/relation/delegation.rb @@ -81,7 +81,9 @@ module ActiveRecord # Cache the constants in @@subclasses because looking them up via const_get # make instantiation significantly slower. def relation_class_for(klass) - if klass && (klass_name = klass.name) + klass_name = klass.name + + if klass_name my_cache = @@subclasses.compute_if_absent(self) { ThreadSafe::Cache.new } # This hash is keyed by klass.name to avoid memory leaks in development mode my_cache.compute_if_absent(klass_name) do |