lib/packer/dataobject.rb in packer-config-1.6.3 vs lib/packer/dataobject.rb in packer-config-1.6.4

- old
+ new

@@ -73,39 +73,45 @@ end def __add_array_of_strings(key, values, exclusives = []) self.__exclusive_key_error(key, exclusives) raise TypeError.new() unless Array.try_convert(values) + self.data[key.to_s] = values.to_ary.map(&:to_s) end def __add_array_of_array_of_strings(key, values, exclusives = []) self.__exclusive_key_error(key, exclusives) raise TypeError.new() unless Array.try_convert(values) + self.data[key.to_s] = [] values.each do |v| raise TypeError.new() unless Array.try_convert(v) + self.data[key.to_s].push(v.to_ary.map(&:to_s)) end end def __add_array_of_hashes(key, values, exclusives = []) self.__exclusive_key_error(key, exclusives) raise TypeError.new() unless Array.try_convert(values) + self.data[key.to_s] = [] values.each do |v| raise TypeError.new() unless v.is_a?(Hash) + self.data[key.to_s].push({}) v.keys.each do |k| self.data[key.to_s][-1][k] = v[k].to_s end end end def __add_array_of_ints(key, values, exclusives = []) self.__exclusive_key_error(key, exclusives) raise TypeError.new() unless Array.try_convert(values) + self.data[key.to_s] = values.to_ary.map(&:to_i) end def __add_string(key, data, exclusives = []) self.__exclusive_key_error(key, exclusives) @@ -124,19 +130,21 @@ end def __add_hash(key, data, exclusives = []) self.__exclusive_key_error(key, exclusives) raise TypeError.new() unless data.is_a?(Hash) + self.data[key.to_s] = {} data.keys.each do |k| self.data[key.to_s][k] = data[k].to_s end end def __add_json(key, data, exclusives = []) self.__exclusive_key_error(key, exclusives) raise TypeError.new() unless data.is_a?(Hash) + self.data[key.to_s] = {} data.keys.each do |k| self.data[key.to_s][k] = data[k] end end