On 23.03.2008 13:05, Trans wrote: > On Mar 23, 7:19 am, Robert Klemme <shortcut... / googlemail.com> wrote: > >> So then the only (?) advantage of your proposal is that you can use >> private methods like ordinary methods. >> >>> There's no need for meta at all, you could just use "class << self" >>> directly, > > Well, yea. > > Wait a minute... could we set the methods we're interested in here to > protected instead of private? And, as you suggest, just use the > singleton class? > > >> def singleton > >> class<<self;self;end > >> end > => nil > >> class Module > >> protected :attr_accessor > >> end > => Module > >> class X > >> singleton.attr_accessor :x > >> end > => nil > >> X.x > => nil > >> X.attr_accessor :y > NoMethodError: protected method `attr_accessor' called for X:Class > from (irb):11 > > Looks good!!! Not sure why this never occurred to me before. See > anything wrong with this approach? At the moment the only thing that bothers me is to change the visibility of some methods of the core lib. I mean, they must be restricted for a reason... Kind regards robert