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, all: false) ⇒ Trigger
constructor
A new instance of Trigger.
Constructor Details
#initialize(app, env, name, triggers, timing, type = :action, all: false) ⇒ Trigger
Returns a new instance of Trigger.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/vagrant/action/builtin/trigger.rb', line 14 def initialize(app, env, name, triggers, timing, type=:action, all: false) @app = app @env = env @triggers = triggers @name = name @timing = timing @type = type @all = all if ![:before, :after].include?(timing) raise ArgumentError, "Invalid value provided for `timing` (allowed: :before or :after)" end end |
Instance Method Details
#call(env) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/vagrant/action/builtin/trigger.rb', line 29 def call(env) machine = env[:machine] machine_name = machine.name if machine @triggers.fire(@name, @timing, machine_name, @type, all: @all) # Carry on @app.call(env) end |