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
|