doc/rdoc/classes/Mongrel/URIClassifier.src/M000089.html in mongrel-0.3.13.4 vs doc/rdoc/classes/Mongrel/URIClassifier.src/M000089.html in mongrel-1.0

- old
+ new

@@ -3,34 +3,37 @@ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> - <title>unregister (Mongrel::URIClassifier)</title> + <title>new (Mongrel::URIClassifier)</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>/** * call-seq: - * uc.unregister(&quot;/someuri&quot;) + * URIClassifier.new -&gt; URIClassifier * - * Yep, just removes this uri and it's handler from the trie. + * Initializes a new URIClassifier object that you can use to associate URI sequences + * with objects. You can actually use it with any string sequence and any objects, + * but it's mostly used with URIs. + * + * It uses TST from http://www.octavian.org/cs/software.html to build an ternary search + * trie to hold all of the URIs. It uses this to do an initial search for the a URI + * prefix, and then to break the URI into SCRIPT_NAME and PATH_INFO portions. It actually + * will do two searches most of the time in order to find the right handler for the + * registered prefix portion. + * */ -VALUE URIClassifier_unregister(VALUE self, VALUE uri) +VALUE URIClassifier_init(VALUE self) { - void *handler = NULL; - struct tst *tst = NULL; - DATA_GET(self, struct tst, tst); + VALUE hash; - handler = tst_delete((unsigned char *)StringValueCStr(uri), tst); + // we create an internal hash to protect stuff from the GC + hash = rb_hash_new(); + rb_ivar_set(self, id_handler_map, hash); - if(handler) { - rb_hash_delete(rb_ivar_get(self, id_handler_map), uri); - - return (VALUE)handler; - } else { - return Qnil; - } + return self; }</pre> </body> </html> \ No newline at end of file