From: Sean Russell Date: 2001-11-05T00:31:55+09:00 Subject: [ruby-talk:24327] Re: RCR: Fun with attribute shortcuts solves RCR #3 and more Dan Schmidt wrote: > Perhaps the generated initialize method could also check for the > presence of a initialize_more (or a better name, hopefully) method > and call it if it exists. > > That way you could set a bunch of member variables automatically, and > then continue by doing other initialization such as setting other > derived variables. Yeah, this would be important. It would be good not to change the original initialization naming scheme, though, and provide an auto-aliasing mechanisem. Although it would introduce a sequence dependability, I was thinking about something like this: # Gunnar's attr_initialize code, up to class_eval, then... if defined? initialize init_code = "alias :__initialize_more__ :initialize def initialize(#{plist}) #{alist} = #{plist} __initialize_more__ end" else init_code = "def initialize(#{plist}); #{alist} = #{plist}; end" end class_eval init_code # ... then the rest of the ends You'd have to define your classes in such a way that your initialize() comes before your attr_initializer statement. Maybe there's a way around this. Anyway, doing it would mean only introducing one new concept (attr_initializer) rather than two (attr_initializer and initialize_more). --- SER -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! Check out our new Unlimited Server. No Download or Time Limits! -----== Over 80,000 Newsgroups - 19 Different Servers! ==-----