From: Bob Hutchison Date: 2001-12-08T05:40:06+09:00 Subject: [ruby-talk:27855] Method creation question Hi, I'm encountering a bit of difficulty and have managed to confuse myself (yet again :-) I'd like to write a function that behaves like 'attr' defining two accessor functions. So, instead of: class Foo attr :bar End I'd like to write: class Foo myAttr :bar end and have two accessor functions added to class Foo. Is this possible? The trouble is that defining the method myAttr requires nesting defs, and this isn't allowed. I thought about procs, but I cannot spot how you'd add a proc to a module/class/object as a method. I've looked around the ruby distribution, 'attr' is defined in one of the C files, so it doesn't provide any clues (to me at least). So this leaves me with eval, as far as I can tell. I've written a module (in util.rb) with this method in it: module Util def Util.myAttr(target, name) doThis = <