diff options
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/base.rb | 9 | ||||
-rw-r--r-- | activerecord/lib/active_record/identity_map.rb | 7 | ||||
-rw-r--r-- | activerecord/lib/active_record/test_case.rb | 2 |
3 files changed, 7 insertions, 11 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 2ac4b6a00a..dd79a6e8d9 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -411,6 +411,10 @@ module ActiveRecord #:nodoc: class_attribute :store_full_sti_class self.store_full_sti_class = true + # Determine whether or not to use IdentityMap. + class_attribute :identity_map + self.identity_map = false + # Stores the default scope for the class class_inheritable_accessor :default_scoping, :instance_writer => false self.default_scoping = [] @@ -425,7 +429,6 @@ module ActiveRecord #:nodoc: delegate :find_each, :find_in_batches, :to => :scoped delegate :select, :group, :order, :except, :limit, :offset, :joins, :where, :preload, :eager_load, :includes, :from, :lock, :readonly, :having, :create_with, :to => :scoped delegate :count, :average, :minimum, :maximum, :sum, :calculate, :to => :scoped - delegate :identity_map=, :to => :identity_map # Executes a custom SQL query against your database and returns all the results. The results will # be returned as an array with columns requested encapsulated as attributes of the model you call @@ -894,11 +897,11 @@ module ActiveRecord #:nodoc: if (column = sti_class.columns_hash[sti_class.primary_key]) && column.number? record_id = record_id.to_i end - if instance = identity_map.get(sti_class, record_id) + if instance = IdentityMap.get(sti_class, record_id) instance.reinit_with('attributes' => record) else instance = sti_class.allocate.init_with('attributes' => record) - identity_map.add(instance) + IdentityMap.add(instance) end else instance = sti_class.allocate.init_with('attributes' => record) diff --git a/activerecord/lib/active_record/identity_map.rb b/activerecord/lib/active_record/identity_map.rb index 70ea08ee43..3ba75a7b59 100644 --- a/activerecord/lib/active_record/identity_map.rb +++ b/activerecord/lib/active_record/identity_map.rb @@ -63,7 +63,6 @@ module ActiveRecord end alias enabled? enabled - alias identity_map= enabled= end self.enabled = false @@ -85,12 +84,6 @@ module ActiveRecord end end - module ClassMethods - def identity_map - ActiveRecord::IdentityMap - end - end - class Middleware def initialize(app) @app = app diff --git a/activerecord/lib/active_record/test_case.rb b/activerecord/lib/active_record/test_case.rb index 09167ba029..4e711c4884 100644 --- a/activerecord/lib/active_record/test_case.rb +++ b/activerecord/lib/active_record/test_case.rb @@ -10,7 +10,7 @@ module ActiveRecord end def cleanup_identity_map - ActiveRecord::Base.identity_map.clear + ActiveRecord::IdentityMap.clear end def assert_date_from_db(expected, actual, message = nil) |