<?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>File: notcopyable.rb</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="fileHeader"> <h1>notcopyable.rb</h1> <table class="header-table"> <tr class="top-aligned-row"> <td><strong>Path:</strong></td> <td>lib/carat/notcopyable.rb </td> </tr> <tr class="top-aligned-row"> <td><strong>Last Update:</strong></td> <td>Mon Apr 11 12:12:50 EDT 2005</td> </tr> </table> </div> <!-- banner header --> <div id="bodyContent"> <div id="contextContent"> <div id="description"> <h1><a href="../../../classes/NotCopyable.html">NotCopyable</a></h1> <p> Disable copying via dup and clone (and copy). </p> <h2>Usage</h2> <pre> require 'carat/notcopyable.rb' Class FixedString < String include NotCopyable end s = FixedString.new("Don't tred on me!") puts s s2 = s.dup </pre> <p> produces </p> <pre> Don't tred on me! TypeError, "Object not copyable" </pre> <h2>Todo</h2> <ul> <li>If one is reopening a class and including this, it will not work if the class defined dub, clone or copy (and deep_copy) itself. It only work if it’s ancestors are responsible for those methods. How to fix? </li> </ul> <h2>Notes</h2> <ul> <li>I don’t think this will prove very useful, but just in case here it is. </li> </ul> <h2>Author(s)</h2> <ul> <li>Paul Brannan <paul at atdesk.com> </li> <li>Thomas Sawyer </li> </ul> <h2>Legal</h2> <p> Adapted from Ruby Treasures 0.4 Copyright (C) 2002 Paul Brannan <paul@atdesk.com> </p> <p> You may distribute this software under the same terms as Ruby (see the file COPYING that was distributed with this library). </p> <h2>History</h2> <ul> <li>2005.04.11 Passed basic test. </li> </ul> </div> </div> </div> <!-- if includes --> <div id="section"> <!-- if method_list --> </div> <div id="validator-badges"> <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p> </div> </body> </html>