<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>run (ActionController::Reloader)</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" /> </head> <body class="standalone-code"> <pre><span class="ruby-comment cmt"># File lib/action_controller/reloader.rb, line 30</span> <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">run</span>(<span class="ruby-identifier">lock</span> = <span class="ruby-ivar">@@default_lock</span>) <span class="ruby-identifier">lock</span>.<span class="ruby-identifier">lock</span> <span class="ruby-keyword kw">begin</span> <span class="ruby-constant">Dispatcher</span>.<span class="ruby-identifier">reload_application</span> <span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">body</span> = <span class="ruby-keyword kw">yield</span> <span class="ruby-comment cmt"># We do not want to call 'cleanup_application' in an ensure block</span> <span class="ruby-comment cmt"># because the returned Rack response body may lazily generate its data. This</span> <span class="ruby-comment cmt"># is for example the case if one calls</span> <span class="ruby-comment cmt">#</span> <span class="ruby-comment cmt"># render :text => lambda { ... code here which refers to application models ... }</span> <span class="ruby-comment cmt">#</span> <span class="ruby-comment cmt"># in an ActionController.</span> <span class="ruby-comment cmt">#</span> <span class="ruby-comment cmt"># Instead, we will want to cleanup the application code after the request is</span> <span class="ruby-comment cmt"># completely finished. So we wrap the body in a BodyWrapper class so that</span> <span class="ruby-comment cmt"># when the Rack handler calls #close during the end of the request, we get to</span> <span class="ruby-comment cmt"># run our cleanup code.</span> [<span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-constant">BodyWrapper</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">body</span>, <span class="ruby-identifier">lock</span>)] <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> <span class="ruby-identifier">lock</span>.<span class="ruby-identifier">unlock</span> <span class="ruby-identifier">raise</span> <span class="ruby-keyword kw">end</span> <span class="ruby-keyword kw">end</span></pre> </body> </html>