Sha256: 75a7b719b2bc50754a9f30c94a5d13a99df38a3eecbf6a244b2cf04f76510397

Contents?: true

Size: 1.1 KB

Versions: 31

Compression:

Stored size: 1.1 KB

Contents

module Vagrant
  module Util
    # Represents the "stacked proc runner" behavior which is used a
    # couple places within Vagrant. This allows procs to "stack" on
    # each other, then all execute in a single action. An example of
    # its uses can be seen in the {Config} class.
    module StackedProcRunner
      # Returns the proc stack. This should always be called as the
      # accessor of the stack. The instance variable itself should _never_
      # be used.
      #
      # @return [Array<Proc>]
      def proc_stack
        @_proc_stack ||= []
      end

      # Adds (pushes) a proc to the stack. The actual proc added here is
      # not executed, but merely stored.
      #
      # @param [Proc] block
      def push_proc(&block)
        proc_stack << block
      end

      # Executes all the procs on the stack, passing in the given arguments.
      # The stack is not cleared afterwards. It is up to the user of this
      # mixin to clear the stack by calling `proc_stack.clear`.
      def run_procs!(*args)
        proc_stack.each do |proc|
          proc.call(*args)
        end
      end
    end
  end
end

Version data entries

31 entries across 27 versions & 4 rubygems

Version Path
vagrant-unbundled-2.3.6.0 lib/vagrant/util/stacked_proc_runner.rb
tamtam-vagrant-reload-1.2.1 vendor/cache/vagrant-2092df529ae7/lib/vagrant/util/stacked_proc_runner.rb
vagrant-unbundled-2.3.3.0 lib/vagrant/util/stacked_proc_runner.rb
vagrant-unbundled-2.3.2.0 lib/vagrant/util/stacked_proc_runner.rb
vagrant-unbundled-2.2.19.0 lib/vagrant/util/stacked_proc_runner.rb
vagrant-unbundled-2.2.18.0 lib/vagrant/util/stacked_proc_runner.rb
vagrant-unbundled-2.2.16.0 lib/vagrant/util/stacked_proc_runner.rb
vagrant-unbundled-2.2.14.0 lib/vagrant/util/stacked_proc_runner.rb
vagrant-aws-mkubenka-0.7.2.pre.24 vendor/bundle/ruby/2.7.0/bundler/gems/vagrant-22795b161bf6/lib/vagrant/util/stacked_proc_runner.rb
vagrant-unbundled-2.2.10.0 lib/vagrant/util/stacked_proc_runner.rb
vagrant-unbundled-2.2.9.0 lib/vagrant/util/stacked_proc_runner.rb
vagrant-unbundled-2.2.8.0 lib/vagrant/util/stacked_proc_runner.rb
vagrant-unbundled-2.2.7.0 lib/vagrant/util/stacked_proc_runner.rb
vagrant-unbundled-2.2.6.2 lib/vagrant/util/stacked_proc_runner.rb
vagrant-unbundled-2.2.6.1 lib/vagrant/util/stacked_proc_runner.rb
vagrant-unbundled-2.2.6.0 lib/vagrant/util/stacked_proc_runner.rb
vagrant-unbundled-2.2.5.0 lib/vagrant/util/stacked_proc_runner.rb
vagrant-unbundled-2.2.4.0 lib/vagrant/util/stacked_proc_runner.rb
vagrant-unbundled-2.2.3.0 lib/vagrant/util/stacked_proc_runner.rb
vagrant-unbundled-2.2.2.0 lib/vagrant/util/stacked_proc_runner.rb