<?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>Class: BasicObject</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", "width=400,height=400,scrollbars=yes" )
        }
      // ]]>
    </script>
  </head>

  <body>
  <table width="100%" border='0' cellpadding='0' cellspacing='0' class='banner'><tr>
  <td class="file-title"><span class="file-title-prefix">Class</span><br />BasicObject</td>
  <td align="right">
    <table cellspacing=0 cellpadding=2>
      <tr valign="top">
        <td>In:</td>
        <td>
<a href="../files/lib/facets/more/basicobject_rb.html">lib/facets/more/basicobject.rb</a>
        </td>
      </tr>
    <tr>
      <td>Parent:</td>
      <td>
        <a href="Object.html">
Object
         </a>
     </td>
   </tr>
         </table>
        </td>
        </tr>
      </table>
 <!-- banner header -->

  <div id="bodyContent">
      <div id="content">

  <div class="description"><h1><a href="BasicObject.html">BasicObject</a></h1>
<p>
<a href="BasicObject.html">BasicObject</a> provides an abstract base class
with no predefined methods, except for <tt>respond_to?</tt>, any method
starting in <tt>__</tt> (two underscore, like <tt>__id__</tt>) as well as
any method starting with &lt;tt&gt;instance_&lt;/ttr&gt;.
</p>
<p>
<a href="BasicObject.html">BasicObject</a> is useful as a base class when
writing classes that depend upon <tt>method_missing</tt> (e.g. dynamic
proxies).
</p>
<p>
The pattern used to reserve methods is:
</p>
<pre>
  /(^__|^instance_|^initialize$|^null$|^inspect$|^dup$|^clone$\?$)/
</pre>
<p>
By default these are the reserved methods:
</p>
<pre>
  __id__ __class__ __self__ __send__ clone dup eql? equal? frozen? initialize
  inspect instance_eval instance_of? instance_variable_get instance_variable_set
  instance_variables is_a? kind_of? nil? null respond_to? tainted?
</pre>
<p>
The special method #<em>self</em> allows access to the underlying object
via a specialized <a href="Functor.html">Functor</a>-style class called, <a
href="BasicObject/Self.html">BasicObject::Self</a>. This binds the actual
self to the subsequently called methods of <a href="Object.html">Object</a>
instancea methods. So even though a method may no longer be defined for <a
href="BasicObject.html">BasicObject</a> it can still be called via this
interface.
</p>
<pre>
  class A &lt; BasicObject
  end

  a.__self__.class  #=&gt; A
  a.class           #=&gt; NoMethodError
</pre>
</div>



  <div class="sectiontitle">Methods</div>
  <ul>
  <li><a href="#M000015">__object__</a></li>
  <li><a href="#M000016">__self__</a></li>
  <li><a href="#M000017">as</a></li>
  <li><a href="#M000018">hide</a></li>
  <li><a href="#M000014">object</a></li>
  </ul>



  <div class="sectiontitle">Classes and Modules</div>
  Class <a href="BasicObject/Self.html" class="link">BasicObject::Self</a><br />


  <div class="sectiontitle">Constants</div>
  <table border='0' cellpadding='5'>
  <tr valign='top'>
    <td class="attr-name">EXCLUDE</td>
    <td>=</td>
    <td class="attr-value">/(^__|^instance|^object|^initialize$|^initialize_copy$|^null$|^inspect$|^dup$|^clone$|^as$|\?$)/</td>
  </tr>
  <tr valign='top'>
    <td>&nbsp;</td>
    <td colspan="2" class="attr-desc">
Methods not to get rid of as they are either too important, or they are not
likely to get in the way (such as methods ending in &#8217;?&#8217;).

</td>
  </tr>
  </table>


<div class="sectiontitle">Public Class methods</div>
<div class="method">
  <div class="title">
    <a name="M000018"></a><b>hide</b>(name)
  </div>
<div class="sourcecode">
  <p class="source-link">[ <a href="javascript:toggleSource('M000018_source')" id="l_M000018_source">show source</a> ]</p>
  <div id="M000018_source" class="dyn-source">
<pre>
<span class="ruby-comment cmt"># File lib/facets/more/basicobject.rb, line 115</span>
  <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">hide</span>(<span class="ruby-identifier">name</span>)
    <span class="ruby-comment cmt">#if instance_methods.include?(name.to_s) and name !~ EXCLUDE #/^(#{EXCLUDE.join('|')})/</span>
    <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">name</span> <span class="ruby-operator">!~</span> <span class="ruby-constant">EXCLUDE</span> <span class="ruby-keyword kw">and</span>
       ( <span class="ruby-identifier">public_instance_methods</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span>) <span class="ruby-keyword kw">or</span>
         <span class="ruby-identifier">private_instance_methods</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span>) <span class="ruby-keyword kw">or</span>
         <span class="ruby-identifier">protected_instance_methods</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span>)
       )
      <span class="ruby-identifier">undef_method</span> <span class="ruby-identifier">name</span>
    <span class="ruby-keyword kw">end</span>
  <span class="ruby-keyword kw">end</span>
</pre>
  </div>
</div>
</div>
<div class="sectiontitle">Public Instance methods</div>
<div class="method">
  <div class="title">
    <a name="M000015"></a><b>__object__</b>()
  </div>
  <div class="description">
  <p>
Alias for <a href="BasicObject.html#M000014">object</a>
</p>
  </div>
</div>
<div class="method">
  <div class="title">
    <a name="M000016"></a><b>__self__</b>()
  </div>
  <div class="description">
  <p>
Alias for <a href="BasicObject.html#M000014">object</a>
</p>
  </div>
</div>
<div class="method">
  <div class="title">
    <a name="M000017"></a><b>as</b>(ancestor)
  </div>
  <div class="description">
  <p>
This method is like <a href="BasicObject.html#M000014">object</a>, but
allows any ancestor to act on behalf of self, not just <a
href="Object.html">Object</a>.
</p>
  </div>
<div class="sourcecode">
  <p class="source-link">[ <a href="javascript:toggleSource('M000017_source')" id="l_M000017_source">show source</a> ]</p>
  <div id="M000017_source" class="dyn-source">
<pre>
<span class="ruby-comment cmt"># File lib/facets/more/basicobject.rb, line 96</span>
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">as</span>(<span class="ruby-identifier">ancestor</span>)
    <span class="ruby-constant">Self</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">ancestor</span>)
  <span class="ruby-keyword kw">end</span>
</pre>
  </div>
</div>
</div>
<div class="method">
  <div class="title">
    <a name="M000014"></a><b>object</b>()
  </div>
  <div class="description">
  <p>
Returns the <a href="BasicObject/Self.html">Self</a> functor class, which
can then be used to call <a href="Kernel.html">Kernel</a>/<a
href="Object.html">Object</a> methods on the current object.
</p>
  </div>
<div class="aka">
  This method is also aliased as
  <a href="BasicObject.html#M000015">__object__</a>
  <a href="BasicObject.html#M000016">__self__</a>
</div>
<div class="sourcecode">
  <p class="source-link">[ <a href="javascript:toggleSource('M000014_source')" id="l_M000014_source">show source</a> ]</p>
  <div id="M000014_source" class="dyn-source">
<pre>
<span class="ruby-comment cmt"># File lib/facets/more/basicobject.rb, line 88</span>
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">object</span>
    <span class="ruby-ivar">@__self__</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">Self</span>.<span class="ruby-identifier">new</span>
  <span class="ruby-keyword kw">end</span>
</pre>
  </div>
</div>
</div>
</div>

  </div>

    </body>
</html>