From: Jamis Buck Date: 2004-09-28T01:45:13+09:00 Subject: Re: local_method_missing possible trans. (T. Onoma) wrote: > On Sunday 26 September 2004 10:33 pm, jim@freeze.org wrote: > >>> class A >>> def a; puts "here"; end >>> end >>> class B < A >>> def b(meth) >>> puts "before" >>> send(meth) >>> puts "after" >>> end >>> def local_method_missing(sym, *args) >>> if /^a/ =~ meth.to_s >>> b(meth) >>> end >>> end >>> end >> >>Could you just use super? >> >> class A >> def a; puts "in a"; end >> end >> class B < A >> def a >> puts "before" >> super >> puts "after" >> end >> end > > > The idea is to submethod multiple methods in one fell-swoop. Hence: > > if /^a/ =~ meth.to_s > > If you have any ideas on other ways to do this, I would love to hear them. Well, it's not very pretty, but what about: 1) aliasing all methods of the subclass to something else (mangling them, basically), 2) Using "method_missing" to intercept and redirect calls to those methods, 3) and using "self.class.instance_methods(false).include?(...)" to determine whether the method was defined in the subclass or a superclass... If this isn't clear enough (and it may very well not be!) I could try posting some pseudo-code... - Jamis -- Jamis Buck jgb3@email.byu.edu http://www.jamisbuck.org/jamis