Sha256: 7370bbeb99d14b72ddf0583a17551a626401cea9fb4781068e1dee5f02c07f76

Contents?: true

Size: 1.1 KB

Versions: 179

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 afterwords. 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

179 entries across 176 versions & 21 rubygems

Version Path
tamtam-vagrant-reload-1.1.3 vendor/cache/vagrant-0ac2a8738841/lib/vagrant/util/stacked_proc_runner.rb
vagrant-unbundled-2.0.3.0 lib/vagrant/util/stacked_proc_runner.rb
vagrant-aws-detiber-0.7.2.pre.4 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-419afb4dcffe/lib/vagrant/util/stacked_proc_runner.rb
vagrant-aws-detiber-0.7.2.pre.3 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-419afb4dcffe/lib/vagrant/util/stacked_proc_runner.rb
vagrant-aws-detiber-0.7.2.pre.2 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-419afb4dcffe/lib/vagrant/util/stacked_proc_runner.rb
vagrant-unbundled-2.0.2.0 lib/vagrant/util/stacked_proc_runner.rb
vagrant-unbundled-2.0.1.0 lib/vagrant/util/stacked_proc_runner.rb
vagrant-aws-mkubenka-0.7.2.pre.22 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-f3fdbf414272/lib/vagrant/util/stacked_proc_runner.rb
vagrant-aws-mkubenka-0.7.2.pre.16 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-1ee58c40e3f5/lib/vagrant/util/stacked_proc_runner.rb
vagrant-unbundled-2.0.0.1 lib/vagrant/util/stacked_proc_runner.rb
vagrant-unbundled-1.9.8.1 lib/vagrant/util/stacked_proc_runner.rb
vagrant-unbundled-1.9.7.1 lib/vagrant/util/stacked_proc_runner.rb
vagrant-aws-mkubenka-0.7.2.pre.14 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/lib/vagrant/util/stacked_proc_runner.rb
vagrant-aws-mkubenka-0.7.2.pre.11 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/lib/vagrant/util/stacked_proc_runner.rb
vagrant-aws-mkubenka-0.7.2.pre.10 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/lib/vagrant/util/stacked_proc_runner.rb
vagrant-aws-mkubenka-0.7.2.pre.9 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/lib/vagrant/util/stacked_proc_runner.rb
vagrant-unbundled-1.9.5.1 lib/vagrant/util/stacked_proc_runner.rb
vagrant-unbundled-1.9.1.1 lib/vagrant/util/stacked_proc_runner.rb
tamtam-vagrant-reload-1.1.2 vendor/cache/vagrant-0ac2a8738841/lib/vagrant/util/stacked_proc_runner.rb
vagrant-compose-yaml-0.1.3 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/lib/vagrant/util/stacked_proc_runner.rb