forked from cheald/mongomapper
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.rb
More file actions
19 lines (19 loc) · 1009 Bytes
/
Copy pathinit.rb
File metadata and controls
19 lines (19 loc) · 1009 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# See http://groups.google.com/group/mongomapper/browse_thread/thread/68f62e8eda43b43a/4841dba76938290c
#
# This is only for development mode. You will still want to clear the identity map before each request in production.
# See examples/identity_map for more on this.
#
# to_prepare is called before each request in development mode and the first request in production.
Rails.configuration.to_prepare do
if Rails.configuration.cache_classes
MongoMapper::Plugins::IdentityMap.clear
else
# Rails reloading was making descendants fill up and leak memory, these make sure they get cleared
MongoMapper::Document.descendants.each {|m| m.descendants.clear if m.respond_to?(:descendants) }
MongoMapper::Document.descendants.clear
MongoMapper::EmbeddedDocument.descendants.each {|m| m.descendants.clear if m.respond_to?(:descendants) }
MongoMapper::EmbeddedDocument.descendants.clear
MongoMapper::Plugins::IdentityMap.clear
MongoMapper::Plugins::IdentityMap.models.clear
end
end