Sha256: 9508299ffa3fbb16a9826b3a036da921261eef3cd3dc9336b53ad716fceb47e2
Contents?: true
Size: 1.05 KB
Versions: 15
Compression:
Stored size: 1.05 KB
Contents
module MongoMapper module Middleware # Usage: # # config.middleware.insert_after \ # ActionDispatch::Callbacks, # MongoMapper::Middleware::IdentityMap # # You have to insert after callbacks so the entire request is wrapped. class IdentityMap class Body extend Forwardable def_delegator :@target, :each def initialize(target, original) @target = target @original = original end def close @target.close if @target.respond_to?(:close) ensure MongoMapper::Plugins::IdentityMap.enabled = @original MongoMapper::Plugins::IdentityMap.clear end end def initialize(app) @app = app end def call(env) MongoMapper::Plugins::IdentityMap.clear enabled = MongoMapper::Plugins::IdentityMap.enabled MongoMapper::Plugins::IdentityMap.enabled = true status, headers, body = @app.call(env) [status, headers, Body.new(body, enabled)] end end end end
Version data entries
15 entries across 15 versions & 1 rubygems