From: Robert Dober Date: 2007-09-01T18:42:14+09:00 Subject: Re: python-style decorators On 8/31/07, Trans wrote: > > > On Aug 31, 12:47 pm, "Robert Dober" wrote: > > > Still trying to get the problem > > I know that you know (do I?) that you can do > > module M > > def foo; "foo" end > > end > > class X > > extend M > > end > > > > where's the catch? > > When you want class-level methods that go along with your instance > methods. > > module M > def self.foo > @foo ||= {} > end > def foo > self.class.foo > end > end > > Class X > include M > end > > X.new.foo #=> ERROR > > If one could include singletons, the solution would be as simple as: > > class X > extend(class << Foo; self; end) > end > > But as things are you need some sort of "trick". Ok I think I got it, thx, I was indeed trying to make Keith's def self.fooized def fooized.try code work but did not see how this was related to the general problem of yours. That is because I got confused what is defined where, well this really is sometimes quite embarrassing, I was sure to get it done, but no such luck .... :( Thx Robert -- I'm an atheist and that's it. I believe there's nothing we can know except that we should be kind to each other and do what we can for other people. -- Katharine Hepburn