vaguerent/lib/vagrant/config/version_base.rb
Mitchell Hashimoto 95e554314e Foundation for supporting multiple version types
I created VersionBase which is the abstract base class for any
configuration versions. Configuration versions are responsible for
knowing how to load configuration given a proc (from a
Vagrant.configure block), as well as merging configuration procs. In the
future, it will have to upgrade versions as well. This is not done yet.

The VERSIONS constant was added to Vagrant::Config which is a registry
to keep track of all the available configuration versions. The
VERSIONS_ORDER constant is an array of the ordering of these versions.
The ordering is important so that in the future Vagrant can attempt to
gracefully upgrade the configurations. It is also used to determine the
current configuration version (which is assumed to be the last version
in the order).

The loader was modified to use the current version and the VERSIONS
registry instead of hardcoding V1.
2012-05-20 17:47:24 -07:00

46 lines
1.8 KiB
Ruby

module Vagrant
module Config
# This is the base class for any configuration versions, and includes
# the stub methods that configuaration versions must implement. Vagrant
# supports configuration versioning so that backwards compatibility can be
# maintained for past Vagrantfiles while newer configurations are added.
# Vagrant only introduces new configuration versions for major versions
# of Vagrant.
class VersionBase
# Returns an empty configuration object. This can be any kind of object,
# since it is treated as an opaque value on the other side, used only
# for things like calling into {merge}.
#
# @return [Object]
def self.init
raise NotImplementedError
end
# Loads the configuration for the given proc and returns a configuration
# object. The return value is treated as an opaque object, so it can be
# anything you'd like. The return value is the object that is passed
# into methods like {merge}, so it should be something you expect.
#
# @param [Proc] proc The proc that is to be configured.
# @return [Object]
def self.load(proc)
raise NotImplementedError
end
# Merges two configuration objects, returning the merged object.
# The values of `old` and `new` are the opaque objects returned by
# {load} or {init}.
#
# Once again, the return object is treated as an opaque value by
# the Vagrant configuration loader, so it can be anything you'd like.
#
# @param [Object] old Old configuration object.
# @param [Object] new New configuration object.
# @return [Object] The merged configuration object.
def self.merge(old, new)
raise NotImplementedError
end
end
end
end