Permalink
Browse files

identity_map name is used for configuration, use IdentityMap to acces…

…s it.
  • Loading branch information...
1 parent 5098302 commit 72aa6f4f649a78b1cd8c7d4340fc143a782728db @miloops miloops committed Nov 18, 2010
@@ -411,6 +411,10 @@ class Base
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 @@ class << self # Class methods
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 @@ def instantiate(record)
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)
@@ -63,7 +63,6 @@ def clear
end
alias enabled? enabled
- alias identity_map= enabled=
end
self.enabled = false
@@ -85,12 +84,6 @@ def reinit_with(coder)
end
end
- module ClassMethods
- def identity_map
- ActiveRecord::IdentityMap
- end
- end
-
class Middleware
def initialize(app)
@app = app
@@ -10,7 +10,7 @@ def setup
end
def cleanup_identity_map
- ActiveRecord::Base.identity_map.clear
+ ActiveRecord::IdentityMap.clear
end
def assert_date_from_db(expected, actual, message = nil)

0 comments on commit 72aa6f4

Please sign in to comment.