<?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>File: eventhook.rb</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" /> <script language="JavaScript" type="text/javascript"> // <![CDATA[ function toggleSource( id ) { var elem var link if( document.getElementById ) { elem = document.getElementById( id ) link = document.getElementById( "l_" + id ) } else if ( document.all ) { elem = eval( "document.all." + id ) link = eval( "document.all.l_" + id ) } else return false; if( elem.style.display == "block" ) { elem.style.display = "none" link.innerHTML = "show source" } else { elem.style.display = "block" link.innerHTML = "hide source" } } function openCode( url ) { window.open( url, "SOURCE_CODE", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=480,width=750" ).focus(); } // ]]> </script> </head> <body> <table border='0' cellpadding='0' cellspacing='0' width="100%" class='banner'> <tr><td> <table width="100%" border='0' cellpadding='0' cellspacing='0'><tr> <td class="file-title" colspan="2"><span class="file-title-prefix">File</span><br />eventhook.rb</td> <td align="right"> <table border='0' cellspacing="0" cellpadding="2"> <tr> <td>Path:</td> <td>lib/facets/eventhook.rb </td> </tr> <tr> <td>Modified:</td> <td>Sat Mar 22 15:46:17 -0400 2008</td> </tr> </table> </td></tr> </table> </td></tr> </table><br /> <!-- banner header --> <div id="bodyContent"> <div id="content"> <div class="description"><h1>Event Hook</h1> <p> Exception-based Event Hooks provides an Event Hooks system designed on top of Ruby‘s built-in Exception system. </p> <pre> def dothis2 puts 'pre' hook :quitit puts 'post' end def tryit2 begin puts "BEFORE" dothis2 puts "AFTER" rescue EventHook event :quitit do puts "HERE" end end end tryit2 </pre> <h2>Authors</h2> <ul> <li>Thomas Sawyer </li> </ul> <h2>Copying</h2> <p> Copyright (c) 2004 Thomas Sawyer </p> <p> Ruby License </p> <p> This module is free software. You may use, modify, and/or redistribute this software under the same terms as Ruby. </p> <p> This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. </p> </div> </div> </div> </body> </html>