Hi all,
I have a mixin module that needs to redefine a particular method if it
already exists and retain a reference to it for later use. This is what
I came up with:
module Example
def Example.included(klass)
if klass.instance_methods.include? "look_inside"
klass.instance_eval { alias_method
:old_look_inside, :look_inside }
klass.send(:define_method, :look_inside) { |event|
#use old_look_inside in here
}
end
end
end
Is there a better/different way of doing this? (This works, I'm just
curious).
-Justin