From: Luis Lavena Date: 2010-06-06T09:35:05+09:00 Subject: Re: 1.9 warning for 'private' and possible bug On Jun 5, 6:25 pm, Joel VanderWerf wrote: > Consider this error: > > $ cat t.rb > module M >    private >    def attr_accessor(*args); super; end > end > > class C >    extend M >    attr_accessor :x > end > > C.new.x = 1 > > $ ruby19 t.rb > t.rb:11:in `
': private method `x=' called for > # (NoMethodError) > > That looks very suspect, so I was about to file a bug report. But then I > noticed that there is a warning reported with the -v switch: > > $ ruby19 -v t.rb > ruby 1.9.2dev (2010-05-31) [x86_64-linux] > t.rb:3: warning: private attribute? > t.rb:11:in `
': private method `x=' called for > # (NoMethodError) > > Does anyone understand this warning? Is 'private' (without an argument) > deprecated? Maybe is because you're setting private for all the following methods, including the ones that attr_accessor defines moving forward after the "extending"? if you change the private to 'private :attr_accessor' there is no warning and things works. -- Luis Lavena