vaguerent/lib/vagrant/util/stacked_proc_runner.rb
Josh Soref 1a5ddea9f4 Spelling fixes
* account
* addresses
* administrator
* afterwards
* because
* bridgeable
* capabilities
* capability
* checksum
* configuration
* configuration for
* configure
* criteria
* delimited
* delivered
* derivatives
* description
* detect
* directory
* display
* downloading
* during
* electric
* enabling
* encountered
* equivalent
* executable
* executed
* hashicorp
* hypervisor
* hyphens
* implementation
* incorporate
* inheritance
* initialize
* instance
* instead
* interactions
* invocable
* machine
* maximum
* message
* mounting
* overridden
* overwrite
* paramiko
* preparing
* provides
* provisioning
* recursively
* requested
* resetting
* retryable
* running
* satisfied
* searching
* sometimes
* specified
* successfully
* synced folders
* unauthorized
* underlying
* userprofile
* vagrant
* vagrantfile
* variable
* various
* version
* virtual
* windows
2018-03-14 14:41:04 +00:00

35 lines
1.1 KiB
Ruby

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