From: Csaba Henk Date: 2004-06-15T18:48:34+09:00 Subject: define_method with singleton classes? Hi! I'd like to use an existing proc object as a method for a singleton class. q = proc { ... } def foo.bar(*a) q[*a] end doesn't work, of course, as q is a local var (and I wouldn't like to pollute the environment with globals...) So what springs to my mind is sending a :define_method to the singleton class... I just can't access that class: class << foo end foo.send(:define_method,:bar,q) => NoMethodError: undefined method `define_method' for # That is, the singleton class is created, but the value of the variable foo (be it anything at this point) doesn't behave as a class, but as the original foo. Any ideas, hints, pointers? Thanks, -- Csaba "There's more to life, than books, you know but not much more..." [The Smiths] *** If you want to send me a mail, see it in the mailto link at http://www.renyi.hu/~ekho/egyelore.html