Hi all,
I would like to override
Capistrano::Configuration::Actions::Invocation#run to add a little
exception handling, namely, to ask if the user would like to continue
anyway. Like so:
def run_with_error_handling(*args, &block)
begin
run_without_error_handling(*args, &block)
rescue Capistrano::CommandError => e
say("#{e}")
continue = confirm("The command failed. Do you want to continue
anyway?")
if (!continue)
bail("Command failed.")
end
end
end
Simple, right? But I can't figure out how to set up the method chain
the right way. Seems like whatever I do, ruby complains that:
`alias_method': undefined method `run' for class `#<Class:
0x126c98c>::Capistrano::Configuration' (NameError)
Huh! I have tried creating a new module with the method and aliases
and including it in Capistrano::Configuration, and I have tried
opening the Capistrano::Configuration::Actions::Invocation module and
adding my aliases there.
Here is what I'm doing:
alias_method(:run_without_error_handling, :run) unless method_defined?
(:run_without_error_handling)
alias_method(:run, :run_with_error_handling)
Can anyone shed a little light on this?
Thanks,
-- Eric
--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---