From: Dan Doel Date: 2003-08-26T04:25:06+09:00 Subject: Re: Aspect oriented Everything? Martin DeMello wrote: >No, because mixins don't let you wrap methods. You can use mixins if >you've designed your code from the start to use mixins that way, but you >can't add them to abn existing codebase (whereas, from what I gather, >you can with aspects). > Actually: class Foo def bar(a) @a = a end end module Aspect def Aspect.append_features(c) c.class_eval do alias_method :oldbar, :bar def bar(a) puts a oldbar a end end super end end class Foo include Aspect end Foo.new.bar 55 - Dan P.S.: I tried doing this by putting the new "def bar(a) ..." stuff in the instance methods of the Aspect module, but it doesn't seem to add them. I'm calling super in append_features, and I tried doing "super c", but that didn't work either. What am I doing wrong?