class MongoMapper::Middleware::IdentityMap

Usage:

config.middleware.insert_after \
  ActionDispatch::Callbacks,
  MongoMapper::Middleware::IdentityMap

You have to insert after callbacks so the entire request is wrapped.

Public Class Methods

new(app) click to toggle source
# File lib/mongo_mapper/middleware/identity_map.rb, line 28
def initialize(app)
  @app = app
end

Public Instance Methods

call(env) click to toggle source
# File lib/mongo_mapper/middleware/identity_map.rb, line 32
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