Class: Vagrant::Action::Builtin::Trigger
- Inherits:
-
Object
- Object
- Vagrant::Action::Builtin::Trigger
- Defined in:
- lib/vagrant/action/builtin/trigger.rb
Overview
This class is used within the Builder class for injecting triggers into different parts of the call stack.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env, name, triggers, timing, type = :action) ⇒ Trigger
constructor
A new instance of Trigger.
Constructor Details
#initialize(app, env, name, triggers, timing, type = :action) ⇒ Trigger
Returns a new instance of Trigger.
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/vagrant/action/builtin/trigger.rb', line 11 def initialize(app, env, name, triggers, timing, type=:action) @app = app @env = env @triggers = triggers @name = name @timing = timing @type = type if ![:before, :after].include?(timing) raise ArgumentError, "Invalid value provided for `timing` (allowed: :before or :after)" end end |
Instance Method Details
#call(env) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/vagrant/action/builtin/trigger.rb', line 25 def call(env) machine = env[:machine] machine_name = machine.name if machine @triggers.fire(@name, @timing, machine_name, @type) # Carry on @app.call(env) end |