Skip to content

Instantly share code, notes, and snippets.

@fabiokr
Created June 4, 2012 17:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabiokr/2869651 to your computer and use it in GitHub Desktop.
Save fabiokr/2869651 to your computer and use it in GitHub Desktop.
class ServiceObserver < ActiveRecord::Observer
def before_activate(service, transition)
return service.driver.provision(transition.args.extract_options!).success?
end
def before_terminate(service, transition)
service.driver.deprovision(transition.args.extract_options!)
end
def before_cancel(service, transition)
service.driver.deprovision(transition.args.extract_options!)
end
def before_suspend(service, transition)
service.driver.suspend(transition.args.extract_options!)
end
def before_resume(service, transition)
service.driver.resume(transition.args.extract_options!)
end
end
@loveybot
Copy link

loveybot commented Jun 4, 2012

Yay Ruby!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment