Monkey patches to a method that exists in a plugin

Say I have a plugin like so:

class Plugin
def do_something
do_thing :one
do_something_else
do_thing :two
end
end

If I want to wrap the call to do_something_else in a begin/rescue
block, then it would seem that I need to either hack the plugin in
vendor/ or put a patch in lib/ that copies a portion of do_something.
Either way, it seems I lose on maintainability.

Is there a convention/method for monkey patching existing methods in
plugins in these situations?

Thanks,
Tom M.klin

On 8 Jan 2009, at 16:37, Tom M wrote:

If I want to wrap the call to do_something_else in a begin/rescue
block, then it would seem that I need to either hack the plugin in
vendor/ or put a patch in lib/ that copies a portion of do_something.
Either way, it seems I lose on maintainability.

The mighty alias_method_chain (which is really just 2 calls to
alias_method) can work here

class Plugin
def do_something_else_with_rescue
begin
do_something_else_without_rescue
rescue …
end
end
alias_method_chain :do_something_else, :rescue
end