Skip to content

Instantly share code, notes, and snippets.

@stve
Created June 4, 2010 17:02
Show Gist options
  • Select an option

  • Save stve/425666 to your computer and use it in GitHub Desktop.

Select an option

Save stve/425666 to your computer and use it in GitHub Desktop.
class Foo
plugin MongoMapper::Plugins::IdentityMap
end
Or you can add to all documents like this:
module IdentityMapAddition
def self.included(model)
model.plugin MongoMapper::Plugins::IdentityMap
end
end
MongoMapper::Document.append_inclusions(IdentityMapAddition)
class PerRequestCache
def initialize(app)
@app = app
end
def call(env)
MongoMapper::Plugins::IdentityMap.clear
@app.call(env)
ensure
MongoMapper::Plugins::IdentityMap.clear
end
end
config.middleware.use 'PerRequestCache'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment