Skip to content

Instantly share code, notes, and snippets.

@fnordfish
Created April 25, 2012 16:21
Show Gist options
  • Save fnordfish/2491039 to your computer and use it in GitHub Desktop.
Save fnordfish/2491039 to your computer and use it in GitHub Desktop.
Register a middleware action from within a plugin
index 0b10045..be73523 100644
--- a/lib/vagrant/plugin/v1.rb
+++ b/lib/vagrant/plugin/v1.rb
@@ -114,6 +114,10 @@ module Vagrant
data[:provisioners]
end
+ def self.action(stack, &block)
+ Vagrant.actions[stack.to_sym].instance_eval(&block)
+ end
+
# Registers the plugin. This makes the plugin actually work with
# Vagrant. Prior to registering, the plugin is merely a skeleton.
def self.register!(plugin=nil)
class Plugin < Vagrant.plugin("1")
# ... includes, name, description ...
# push my middleware on the start stack
action(:start) {
use MyAction
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment