aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2010-11-18 17:23:59 -0300
committerEmilio Tagua <miloops@gmail.com>2010-11-19 19:09:00 -0300
commit72aa6f4f649a78b1cd8c7d4340fc143a782728db (patch)
tree451550b35a7515ef5b04ceca80764db32140e7b7
parent5098302fa102441be1a93266817994a3e31be4b1 (diff)
downloadrails-72aa6f4f649a78b1cd8c7d4340fc143a782728db.tar.gz
rails-72aa6f4f649a78b1cd8c7d4340fc143a782728db.tar.bz2
rails-72aa6f4f649a78b1cd8c7d4340fc143a782728db.zip
identity_map name is used for configuration, use IdentityMap to access it.
-rw-r--r--activerecord/lib/active_record/base.rb9
-rw-r--r--activerecord/lib/active_record/identity_map.rb7
-rw-r--r--activerecord/lib/active_record/test_case.rb2
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)