aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/identity_map.rb
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2010-10-15 15:44:21 -0300
committerEmilio Tagua <miloops@gmail.com>2010-11-19 19:08:55 -0300
commit08c37b7ed8281bc3e3c1eca98a4859017c89157a (patch)
tree529919fbe6b60edf4498051728b79ed13656376a /activerecord/lib/active_record/identity_map.rb
parent3a34ae04bdf5e0badc85daef5f204d02688f193d (diff)
downloadrails-08c37b7ed8281bc3e3c1eca98a4859017c89157a.tar.gz
rails-08c37b7ed8281bc3e3c1eca98a4859017c89157a.tar.bz2
rails-08c37b7ed8281bc3e3c1eca98a4859017c89157a.zip
Use block syntax in IdentityMap middleware.
Diffstat (limited to 'activerecord/lib/active_record/identity_map.rb')
-rw-r--r--activerecord/lib/active_record/identity_map.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/identity_map.rb b/activerecord/lib/active_record/identity_map.rb
index cca4198c69..30a2a1eb0f 100644
--- a/activerecord/lib/active_record/identity_map.rb
+++ b/activerecord/lib/active_record/identity_map.rb
@@ -27,7 +27,12 @@ module ActiveRecord
end
def use
+ old, self.enabled = self.enabled, true
+
yield if block_given?
+ ensure
+ self.enabled = old
+ ActiveRecord::IdentityMap.clear
end
def without
@@ -93,9 +98,9 @@ module ActiveRecord
end
def call(env)
- @app.call(env)
- ensure
- ActiveRecord::IdentityMap.clear
+ ActiveRecord::IdentityMap.use do
+ @app.call(env)
+ end
end
end
end