From: ruud grosmann Date: 2008-09-30T20:01:45+09:00 Subject: Re: extend keyword in class definition OK. I think now I get what you mean. To make sure I understood it right: my mistake was that there are both singleton methods on classes and singleton methods on instances of a class. Essentially the same, because classes are objects too. In this case, we're talking about singleton methods on the class WriterDecorator. This is done because the Forwardable method 'def_delegators' is used by the class object only, not by it's instances. Which would have been the case if Forwardable was mixed in. Please correct me if I'm wrong. Thanks anyway for the time spent on helping me on this! regards, Ruud On 30/09/2008, David A. Black wrote: > Hi -- > > On Tue, 30 Sep 2008, Sebastian Hungerecker wrote: > >> ruud grosmann wrote: >>> Isn't a singleton method a method that applies to the >>> singleton class of one object? >> >> It is a method that is defined on the singleton class of an object, yes. >> As a singleton class by definition only has one instance that means that a >> singleton method is a method that can be called on a single object and >> that >> object only. > > Although: > > class C > end > class D < C > end > > def C.x > end > > D.x # subclass can call superclass's singleton methods > > Technically, it's also true that if you extend an object with a > module, you're not really writing singleton methods, since the methods > in the module are available to other objects that use the module. The > singleton_method_added callback won't get called, for example. > > > David > > -- > Rails training from David A. Black and Ruby Power and Light: > Intro to Ruby on Rails January 12-15 Fort Lauderdale, FL > Advancing with Rails January 19-22 Fort Lauderdale, FL * > * Co-taught with Patrick Ewing! > See http://www.rubypal.com for details and updates! > >