Created
March 27, 2012 19:17
-
-
Save darrinholst/2219405 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Chef | |
class Resource | |
class Deploy < Chef::Resource | |
def on_start(arg=nil, &block) | |
arg ||= block | |
set_or_return(:on_start, arg, :kind_of => [Proc, String]) | |
end | |
def on_complete(arg=nil, &block) | |
arg ||= block | |
set_or_return(:on_complete, arg, :kind_of => [Proc, String]) | |
end | |
def on_error(arg=nil, &block) | |
arg ||= block | |
set_or_return(:on_error, arg, :kind_of => [Proc, String]) | |
end | |
end | |
end | |
end | |
class Chef | |
class Provider | |
class Deploy < Chef::Provider | |
alias :old_deploy :deploy | |
def deploy | |
begin | |
callback(:on_start, @new_resource.on_start) | |
old_deploy | |
callback(:on_complete, @new_resource.on_complete) | |
rescue => e | |
callback(:on_error, @new_resource.on_error) | |
raise e | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment