Sha256: b55ae1e8fbe1dc7c50dbc002457090e78e92418436ce3994f43869db95f7f937

Contents?: true

Size: 1002 Bytes

Versions: 7

Compression:

Stored size: 1002 Bytes

Contents

module VagrantPlugins
  module Invade
    module Validator
      module Type

        class HashValidator

          attr_accessor :value, :name, :default, :env

          def initialize(value, name, default, env)
            @value = value
            @name = name
            @default = default
            @env = env
          end

          def validate

            if @value.is_a?(Hash)
              @env[:ui].success("\t#{name} => #{@value}") unless @env[:invade_validate_quiet]
            elsif @value === nil
              @env[:ui].warn("\t#{name} not set. Use Vagrant default.") unless @env[:invade_validate_quiet]

              return default
            else
              @env[:ui].error("\tError: '#{@value}' is not a Hash. Set '#{name}' to default value #{default}.") unless @env[:invade_validate_quiet]

              @validation_errors = @validation_errors + 1
              return default
            end

            @value
          end
        end

      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
vagrant-invade-0.8.0 lib/vagrant-invade/validator/type/type_hash.rb
vagrant-invade-0.7.0 lib/vagrant-invade/validator/type/type_hash.rb
vagrant-invade-0.6.4 lib/vagrant-invade/validator/type/type_hash.rb
vagrant-invade-0.6.3 lib/vagrant-invade/validator/type/type_hash.rb
vagrant-invade-0.6.2 lib/vagrant-invade/validator/type/type_hash.rb
vagrant-invade-0.6.1 lib/vagrant-invade/validator/type/type_hash.rb
vagrant-invade-0.6.0 lib/vagrant-invade/validator/type/type_hash.rb