Class: MongoMapper::Middleware::IdentityMap
- Defined in:
- lib/mongo_mapper/middleware/identity_map.rb
Overview
Usage:
config.middleware.insert_after \
ActionDispatch::Callbacks,
MongoMapper::Middleware::IdentityMap
You have to insert after callbacks so the entire request is wrapped.
Defined Under Namespace
Classes: Body
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ IdentityMap
constructor
A new instance of IdentityMap.
Constructor Details
#initialize(app) ⇒ IdentityMap
Returns a new instance of IdentityMap.
28 29 30 |
# File 'lib/mongo_mapper/middleware/identity_map.rb', line 28 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
32 33 34 35 36 37 38 |
# 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 |