diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-05-03 09:52:41 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-05-03 09:59:22 -0700 |
commit | d0719c59384c387aebfdc4a78f6e985bcf5bb270 (patch) | |
tree | 84430a5ee109fbb3bdbd7a2ec2f7753cb786d116 /activerecord/lib/active_record | |
parent | 3f897c1a4cef0cb9b53234e10d10d4b8744d61b0 (diff) | |
download | rails-d0719c59384c387aebfdc4a78f6e985bcf5bb270.tar.gz rails-d0719c59384c387aebfdc4a78f6e985bcf5bb270.tar.bz2 rails-d0719c59384c387aebfdc4a78f6e985bcf5bb270.zip |
proxying the body in the IM middleware so that IM is available for streaming ERb
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/identity_map.rb | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/identity_map.rb b/activerecord/lib/active_record/identity_map.rb index 4ad0b0d205..647f9e11d2 100644 --- a/activerecord/lib/active_record/identity_map.rb +++ b/activerecord/lib/active_record/identity_map.rb @@ -98,14 +98,32 @@ module ActiveRecord end class Middleware + class Body #:nodoc: + def initialize(target, original) + @target = target + @original = original + end + + def each(&block) + @target.each(&block) + end + + def close + @target.close if @target.respond_to?(:close) + ensure + IdentityMap.enabled = @original + end + end + def initialize(app) @app = app end def call(env) - ActiveRecord::IdentityMap.use do - @app.call(env) - end + enabled = IdentityMap.enabled + IdentityMap.enabled = true + status, headers, body = @app.call(env) + [status, headers, Body.new(body, enabled)] end end end |