Aleks Kissinger
8/30/2006 3:19:00 PM
That works. So the final code would be something like:
module TestExtension
def inject_methods(base)
base.module_eval do
def self.my_method
"overridden by TestExtension"
end
end
end
def extended(base)
inject_methods(base)
end
def included(base)
inject_methods(base)
end
end
This has always been a little clunky in Ruby, primarily because
methods written within a specific class were designed to override
mixin and parent class methods, not vice-versa.
On 8/30/06, Jan Svitok <jan.svitok@gmail.com> wrote:
> On 8/30/06, John W. Long <ng@johnwlong.com> wrote:
> > Trans wrote:
> > > Okay a more presently practical answer. You can use a hack like:
> > >
> > > module TestExtension
> > > def self.included(base)
>
> shouldn't be "extended" ?
>
> > > base.module_eval do
> > > def my_method
> > > "overridden by TestExtension"
> > > end
> > > end
> > > end
> > > def another_method
> > > "another method"
> > > end
> > > end
> >
> > Mmm. That doesn't work either.
>
>