256
257
258
259
260
261
262
263
264
265
266
267
268
|
# File 'lib/connect/dsl.rb', line 256
def add_objects_with_iterators(type, name, values, xdef, iterators)
name = interpolated_value(name)
iterator_values = {}
iterators.each_pair {|k,v| iterator_values[k] = values_from_iterator(v,k)}
max_size = iterator_values.collect{|k,v| v.size}.max
iterator_values.each_pair {|k,v| iterator_values[k] = v * ((max_size/v.size) + (max_size % v.size))}
(0..max_size).each do | index|
value_hash = iterator_values.keys.reduce({}) {|v,k| v.merge!({k.to_sym => iterator_values[k][index]})}
object_name = name % value_hash
object_values = substitute_values(values, value_hash)
add_object(type, object_name, object_values, xdef)
end
end
|