216: def pathhashlist(key, arr_of_hashes, mappings)
217: raise ArgumentError, "expected a key that is a String" unless key.is_a? String
218: raise ArgumentError, "expected a arr_of_hashes that is an Array" unless arr_of_hashes.is_a? Array
219: arr_of_hashes.each{|h| raise ArgumentError, "expected each element of arr_of_hashes to be a Hash" unless h.is_a?(Hash)}
220: raise ArgumentError, "expected a mappings that is an Hash" unless mappings.is_a? Hash
221: params = {}
222: arr_of_hashes.each_with_index do |hash, i|
223: hash.each do |attribute, value|
224: if value.is_a? Array
225: params["#{key}.#{i+1}.Name"] = mappings[attribute]
226: value.each_with_index do |item, j|
227: params["#{key}.#{i+1}.Value.#{j+1}"] = item.to_s
228: end
229: else
230: params["#{key}.#{i+1}.#{mappings[attribute]}"] = value.to_s
231: end
232: end
233: end
234: params
235: end