Permalink
Browse files

refactor

  • Loading branch information...
jonleighton committed Jun 15, 2012
1 parent 9abe098 commit 61826bcca3481a85649be714a91a45ca909f2726
Showing with 5 additions and 11 deletions.
  1. +5 −11 activerecord/lib/active_record/railtie.rb
@@ -97,18 +97,12 @@ class Railtie < Rails::Railtie
end
initializer "active_record.set_reloader_hooks" do |app|
- hook = lambda do
- ActiveRecord::Base.clear_reloadable_connections!
- ActiveRecord::Base.clear_cache!
- end
+ hook = app.config.reload_classes_only_on_change ? :to_prepare : :to_cleanup
- if app.config.reload_classes_only_on_change
- ActiveSupport.on_load(:active_record) do
- ActionDispatch::Reloader.to_prepare(&hook)
- end
- else
- ActiveSupport.on_load(:active_record) do
- ActionDispatch::Reloader.to_cleanup(&hook)
+ ActiveSupport.on_load(:active_record) do
+ ActionDispatch::Reloader.send(hook) do
+ ActiveRecord::Base.clear_reloadable_connections!
+ ActiveRecord::Base.clear_cache!
end
end
end

0 comments on commit 61826bc

Please sign in to comment.