Sha256: 5f4382221a100012c6b3fb21eba8e9f0dc405912e25d740418cb2b0b744a6a0e

Contents?: true

Size: 1.18 KB

Versions: 10

Compression:

Stored size: 1.18 KB

Contents

module Vagrant
  module Action
    module Builtin
      # This class is used within the Builder class for injecting triggers into
      # different parts of the call stack.
      class Trigger
        # @param [Class, String, Symbol] name Name of trigger to fire
        # @param [Vagrant::Plugin::V2::Triger] triggers Trigger object
        # @param [Symbol] timing When trigger should fire (:before/:after)
        # @param [Symbol] type Type of trigger
        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

        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
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 3 rubygems

Version Path
vagrant-unbundled-2.3.6.0 lib/vagrant/action/builtin/trigger.rb
tamtam-vagrant-reload-1.2.1 vendor/cache/vagrant-2092df529ae7/lib/vagrant/action/builtin/trigger.rb
vagrant-unbundled-2.3.3.0 lib/vagrant/action/builtin/trigger.rb
vagrant-unbundled-2.3.2.0 lib/vagrant/action/builtin/trigger.rb
vagrant-unbundled-2.2.19.0 lib/vagrant/action/builtin/trigger.rb
vagrant-unbundled-2.2.18.0 lib/vagrant/action/builtin/trigger.rb
vagrant-unbundled-2.2.16.0 lib/vagrant/action/builtin/trigger.rb
vagrant-unbundled-2.2.14.0 lib/vagrant/action/builtin/trigger.rb
vagrant-aws-mkubenka-0.7.2.pre.24 vendor/bundle/ruby/2.7.0/bundler/gems/vagrant-22795b161bf6/lib/vagrant/action/builtin/trigger.rb
vagrant-unbundled-2.2.10.0 lib/vagrant/action/builtin/trigger.rb