Recursively normalize the given data structure
@api public @raise [NormalizationError] If the data structure contained an invalid element. @return [void]
# File lib/facter/util/normalization.rb, line 15 def normalize(value) case value when Integer, Float, TrueClass, FalseClass, NilClass value when String normalize_string(value) when Array normalize_array(value) when Hash normalize_hash(value) else raise NormalizationError, "Expected #{value} to be one of #{VALID_TYPES.inspect}, but was #{value.class}" end end
Validate all elements of the array.
@api public @raise [NormalizationError] If one of the elements failed validation @param value [Array] @return [void]
# File lib/facter/util/normalization.rb, line 77 def normalize_array(value) value.collect do |elem| normalize(elem) end end
Validate all keys and values of the hash.
@api public @raise [NormalizationError] If one of the keys or values failed normalization @param value [Hash] @return [void]
# File lib/facter/util/normalization.rb, line 89 def normalize_hash(value) Hash[value.collect { |k, v| [ normalize(k), normalize(v) ] } ] end
Generated with the Darkfish Rdoc Generator 2.