<?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: GemPlugin::Manager</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">GemPlugin::Manager</td> </tr> <tr class="top-aligned-row"> <td><strong>In:</strong></td> <td> <a href="../../files/lib/gem_plugin_rb.html"> lib/gem_plugin.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> This class is used by people who use gem plugins (but don’t necessarily make them) to add plugins to their own systems. It provides a way to load plugins, list them, and create them as needed. </p> <p> It is a singleton so you use like this: GemPlugins::Manager.instance.load </p> </div> </div> <div id="method-list"> <h3 class="section-bar">Methods</h3> <div class="name-list"> <a href="#M000009">available</a> <a href="#M000008">create</a> <a href="#M000006">load</a> <a href="#M000005">new</a> <a href="#M000007">register</a> </div> </div> </div> <!-- if includes --> <div id="includes"> <h3 class="section-bar">Included Modules</h3> <div id="includes-list"> <span class="include-name">Singleton</span> </div> </div> <div id="section"> <!-- if method_list --> <div id="methods"> <h3 class="section-bar">Public Class methods</h3> <div id="method-M000005" class="method-detail"> <a name="M000005"></a> <div class="method-heading"> <a href="Manager.src/M000005.html" target="Code" class="method-signature" onclick="popupCode('Manager.src/M000005.html');return false;"> <span class="method-name">new</span><span class="method-args">()</span> </a> </div> <div class="method-description"> </div> </div> <h3 class="section-bar">Public Instance methods</h3> <div id="method-M000009" class="method-detail"> <a name="M000009"></a> <div class="method-heading"> <a href="Manager.src/M000009.html" target="Code" class="method-signature" onclick="popupCode('Manager.src/M000009.html');return false;"> <span class="method-name">available</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Returns a map of URIs->{"name" => Plugin} that you can use to investigate available handlers. </p> </div> </div> <div id="method-M000008" class="method-detail"> <a name="M000008"></a> <div class="method-heading"> <a href="Manager.src/M000008.html" target="Code" class="method-signature" onclick="popupCode('Manager.src/M000008.html');return false;"> <span class="method-name">create</span><span class="method-args">(name, options = {})</span> </a> </div> <div class="method-description"> <p> Resolves the given name (should include /category/name) to find the plugin class and create an instance. You can pass a second hash option that is then given to the Plugin to configure it. </p> </div> </div> <div id="method-M000006" class="method-detail"> <a name="M000006"></a> <div class="method-heading"> <a href="Manager.src/M000006.html" target="Code" class="method-signature" onclick="popupCode('Manager.src/M000006.html');return false;"> <span class="method-name">load</span><span class="method-args">(needs = {})</span> </a> </div> <div class="method-description"> <p> Responsible for going through the list of available gems and loading any plugins requested. It keeps track of what it’s loaded already and won’t load them again. </p> <p> It accepts one parameter which is a hash of gem depends that should include or exclude a gem from being loaded. A gem must depend on gem_plugin to be considered, but then each system has to add it’s own INCLUDE to make sure that only plugins related to it are loaded. </p> <p> An example again comes from Mongrel. In order to load all Mongrel plugins: </p> <pre> GemPlugin::Manager.instance.load "mongrel" => GemPlugin::INCLUDE </pre> <p> Which will load all plugins that depend on mongrel AND gem_plugin. Now, one extra thing we do is we delay loading Rails Mongrel plugins until after rails is configured. Do do this the mongrel_rails script has: </p> <pre> GemPlugin::Manager.instance.load "mongrel" => GemPlugin::INCLUDE, "rails" => GemPlugin::EXCLUDE </pre> <p> The only thing to remember is that this is saying "include a plugin if it depends on gem_plugin, mongrel, but NOT rails". If a plugin also depends on other stuff then it’s loaded just fine. Only gem_plugin, mongrel, and rails are ever used to determine if it should be included. </p> </div> </div> <div id="method-M000007" class="method-detail"> <a name="M000007"></a> <div class="method-heading"> <a href="Manager.src/M000007.html" target="Code" class="method-signature" onclick="popupCode('Manager.src/M000007.html');return false;"> <span class="method-name">register</span><span class="method-args">(category, name, klass)</span> </a> </div> <div class="method-description"> <p> Not necessary for you to call directly, but this is how <a href="Base.html#M000002">GemPlugin::Base.inherited</a> actually adds a plugin to a category. </p> </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>