ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> ruby-talk
ruby-talk
Where is attr_accessor located?
by Mariano Kamp other posts by this author
Nov 12 2006 10:16AM messages near this date
Re: Test::Unit runner for HTML output | Re: Where is attr_accessor located?
Hi,

   I am a bit confused. I get different responses when asking RI and  
IRB. It's probably just me not understanding to read the output or  
issue the right queries.

   When calling "ri attr_accesor" I get the following:

localhost:~ mkamp$ ri attr_accessor
--------------------------------------------------- Module#attr_accessor
      attr_accessor(symbol, ...)    =>  nil
------------------------------------------------------------------------
      Equivalent to calling ``+attr+_symbol_+, true+'' on each _symbol_
      in turn.

         module Mod
           attr_accessor(:one, :two)
         end
         Mod.instance_methods.sort   #=>  ["one", "one=", "two", "two="]

   That would mean attr_accesor is in Module right?

   Please look at this IRB session:

localhost:~ mkamp$ irb
 > > Module.private_methods.grep /attr/
=>  ["attr", "attr_reader", "attr_writer", "attr_accessor"]
 > > Module.private_methods(false).grep /attr/
=>  []
 > > Kernel.private_methods(false).grep /attr/
=>  ["attr", "attr_reader", "attr_writer", "attr_accessor"]

   Why is that? After looking at the rdoc documentation I would have  
assumed that attr_accessor would be a private method of Module, not  
of Kernel.

   Any idea?

Cheers,
Mariano
Thread:
Mariano Kamp
Ross Bamford
Mariano Kamp
Mauricio Fernandez
Mariano Kamp

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved