<?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 xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Class: ActiveRecord::ConnectionAdapters::ConnectionHandler</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta http-equiv="Content-Script-Type" content="text/javascript" /> <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" /> <script type="text/javascript"> // <![CDATA[ function popupCode( url ) { window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400") } function toggleCode( id ) { if ( document.getElementById ) elem = document.getElementById( id ); else if ( document.all ) elem = eval( "document.all." + id ); else return false; elemStyle = elem.style; if ( elemStyle.display != "block" ) { elemStyle.display = "block" } else { elemStyle.display = "none" } return true; } // Make codeblocks hidden by default document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" ) // ]]> </script> </head> <body> <div id="classHeader"> <table class="header-table"> <tr class="top-aligned-row"> <td><strong>Class</strong></td> <td class="class-name-in-header">ActiveRecord::ConnectionAdapters::ConnectionHandler</td> </tr> <tr class="top-aligned-row"> <td><strong>In:</strong></td> <td> <a href="../../../files/lib/active_record/connection_adapters/abstract/connection_pool_rb.html"> lib/active_record/connection_adapters/abstract/connection_pool.rb </a> <br /> </td> </tr> <tr class="top-aligned-row"> <td><strong>Parent:</strong></td> <td> Object </td> </tr> </table> </div> <!-- banner header --> <div id="bodyContent"> <div id="contextContent"> <div id="description"> <p> <a href="ConnectionHandler.html">ConnectionHandler</a> is a collection of <a href="ConnectionPool.html">ConnectionPool</a> objects. It is used for keeping separate connection pools for ActiveRecord models that connect to different databases. </p> <p> For example, suppose that you have 5 models, with the following hierarchy: </p> <pre> | +-- Book | | | +-- ScaryBook | +-- GoodBook +-- Author +-- BankAccount </pre> <p> Suppose that Book is to connect to a separate database (i.e. one other than the default database). Then Book, ScaryBook and GoodBook will all use the same connection pool. Likewise, Author and BankAccount will use the same connection pool. However, the connection pool used by Author/BankAccount is not the same as the one used by Book/ScaryBook/GoodBook. </p> <p> Normally there is only a single <a href="ConnectionHandler.html">ConnectionHandler</a> instance, accessible via ActiveRecord::Base.connection_handler. ActiveRecord models use this to determine that connection pool that they should use. </p> </div> </div> <div id="method-list"> <h3 class="section-bar">Methods</h3> <div class="name-list"> <a href="#M000275">clear_active_connections!</a> <a href="#M000277">clear_all_connections!</a> <a href="#M000276">clear_reloadable_connections!</a> <a href="#M000278">connected?</a> <a href="#M000273">connection_pools</a> <a href="#M000274">establish_connection</a> <a href="#M000272">new</a> <a href="#M000279">remove_connection</a> <a href="#M000280">retrieve_connection_pool</a> </div> </div> </div> <!-- if includes --> <div id="section"> <!-- if method_list --> <div id="methods"> <h3 class="section-bar">Public Class methods</h3> <div id="method-M000272" class="method-detail"> <a name="M000272"></a> <div class="method-heading"> <a href="ConnectionHandler.src/M000272.html" target="Code" class="method-signature" onclick="popupCode('ConnectionHandler.src/M000272.html');return false;"> <span class="method-name">new</span><span class="method-args">(pools = {})</span> </a> </div> <div class="method-description"> </div> </div> <h3 class="section-bar">Public Instance methods</h3> <div id="method-M000275" class="method-detail"> <a name="M000275"></a> <div class="method-heading"> <a href="ConnectionHandler.src/M000275.html" target="Code" class="method-signature" onclick="popupCode('ConnectionHandler.src/M000275.html');return false;"> <span class="method-name">clear_active_connections!</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Returns any connections in use by the current thread back to the pool, and also returns connections to the pool cached by threads that are no longer alive. </p> </div> </div> <div id="method-M000277" class="method-detail"> <a name="M000277"></a> <div class="method-heading"> <a href="ConnectionHandler.src/M000277.html" target="Code" class="method-signature" onclick="popupCode('ConnectionHandler.src/M000277.html');return false;"> <span class="method-name">clear_all_connections!</span><span class="method-args">()</span> </a> </div> <div class="method-description"> </div> </div> <div id="method-M000276" class="method-detail"> <a name="M000276"></a> <div class="method-heading"> <a href="ConnectionHandler.src/M000276.html" target="Code" class="method-signature" onclick="popupCode('ConnectionHandler.src/M000276.html');return false;"> <span class="method-name">clear_reloadable_connections!</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Clears the cache which maps classes </p> </div> </div> <div id="method-M000278" class="method-detail"> <a name="M000278"></a> <div class="method-heading"> <a href="ConnectionHandler.src/M000278.html" target="Code" class="method-signature" onclick="popupCode('ConnectionHandler.src/M000278.html');return false;"> <span class="method-name">connected?</span><span class="method-args">(klass)</span> </a> </div> <div class="method-description"> <p> Returns true if a connection that‘s accessible to this class has already been opened. </p> </div> </div> <div id="method-M000273" class="method-detail"> <a name="M000273"></a> <div class="method-heading"> <a href="ConnectionHandler.src/M000273.html" target="Code" class="method-signature" onclick="popupCode('ConnectionHandler.src/M000273.html');return false;"> <span class="method-name">connection_pools</span><span class="method-args">()</span> </a> </div> <div class="method-description"> </div> </div> <div id="method-M000274" class="method-detail"> <a name="M000274"></a> <div class="method-heading"> <a href="ConnectionHandler.src/M000274.html" target="Code" class="method-signature" onclick="popupCode('ConnectionHandler.src/M000274.html');return false;"> <span class="method-name">establish_connection</span><span class="method-args">(name, spec)</span> </a> </div> <div class="method-description"> </div> </div> <div id="method-M000279" class="method-detail"> <a name="M000279"></a> <div class="method-heading"> <a href="ConnectionHandler.src/M000279.html" target="Code" class="method-signature" onclick="popupCode('ConnectionHandler.src/M000279.html');return false;"> <span class="method-name">remove_connection</span><span class="method-args">(klass)</span> </a> </div> <div class="method-description"> <p> Remove the connection for this class. This will close the active connection and the defined connection (if they exist). The result can be used as an argument for <a href="ConnectionHandler.html#M000274">establish_connection</a>, for easily re-establishing the connection. </p> </div> </div> <div id="method-M000280" class="method-detail"> <a name="M000280"></a> <div class="method-heading"> <a href="ConnectionHandler.src/M000280.html" target="Code" class="method-signature" onclick="popupCode('ConnectionHandler.src/M000280.html');return false;"> <span class="method-name">retrieve_connection_pool</span><span class="method-args">(klass)</span> </a> </div> <div class="method-description"> </div> </div> </div> </div> <div id="validator-badges"> <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p> </div> </body> </html>