From: Drew Olson Date: 2007-10-27T03:15:00+09:00 Subject: Re: Need help understanding metaclassing Chris Czub wrote: > Drew Olson wrote: >> Chris Czub wrote: >>> Any ideas? >> >> Basically the same idea as why's solution to dwenthy's array: > > Someone else responded with: > "You added a singleton method email and an accessor pair email/email= to > the User class. The email method with no arguments called on User > instances is the reader, you need to use the email= method." > > which is correct - the method user.email("") only works from the > standpoint of the singleton, but you CAN call user.email = "bla" from > outside the singleton context. Not really sure what you're asking here, but I can tell you what my code does. It adds methods to the metaclass associated with each symbol passed to the attribs method. These essentially act like class methods for any class the inherits from User. Then, I add a instance method #initialize that is called when new objects are created and sets the instance variables for that object to the values given in the class methods. Make sense? -- Posted via http://www.ruby-forum.com/.