From: gabriele renzi Date: 2003-06-30T03:31:34+09:00 Subject: Re: Help with UnboundMethod#bind error il Mon, 30 Jun 2003 01:43:03 +0900, nobu.nokada@softhome.net ha scritto:: >Although I'm not sure what you really want, try instance_method >instead. I was wondering of a quick way to decorate a method: - unbind the method my_met() from its current object (actually, I was thinking about method defined out of class definitions, 'function'-like ) - put my_met() in a different module - define a new my_met() using the old one. >> m=Kernel.method( :met).unbind > m=Kernel.instance_method(:met) well, I just thought the same thing, I had the thing working in this way: >> def met >> puts 'bau' >> end => nil >> m=Object.instance_method(:met) => # >> module M >> end => nil >> m.bind(M) => # If I try Kernel.instance_method I have a NameError. >> now: I know that Mod is a different object. Anyway MEthod#bind should >> worry just about obj.class, am I wrong ? > >Modules and classes always have metaclasses. emh.. yeah I should have remembered this.. >It might be ok to ignore metaclasses have no influence. cool, that's the first time that I get a patch just for my own purpose ^_^ thank you very much PS anyway, my idea fails, it would have been to cool if it worked. If I try to redefine my_met() as a "function" it gets propagated to MyModule, and I fall in a 'stack level too deep' error. I suppose I need a freeze-like feature to avoid MyModule from inherithing Kernel for a while.. and then inherithing it again.. Ok, I suppose I just need to sleep...