Class: Vagrant::Action::Builtin::ConfigValidate
- Inherits:
-
Object
- Object
- Vagrant::Action::Builtin::ConfigValidate
- Defined in:
- lib/vagrant/action/builtin/config_validate.rb
Overview
This class validates the configuration and raises an exception if there are any validation errors.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ ConfigValidate
constructor
A new instance of ConfigValidate.
Constructor Details
#initialize(app, env) ⇒ ConfigValidate
Returns a new instance of ConfigValidate.
9 10 11 |
# File 'lib/vagrant/action/builtin/config_validate.rb', line 9 def initialize(app, env) @app = app end |
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/vagrant/action/builtin/config_validate.rb', line 13 def call(env) if !env.has_key?(:config_validate) || env[:config_validate] errors = env[:machine].config.validate(env[:machine]) if errors && !errors.empty? raise Errors::ConfigInvalid, :errors => Util::TemplateRenderer.render( "config/validation_failed", :errors => errors) end end @app.call(env) end |