lib/sportradar/api/data.rb in sportradar-api-0.9.34 vs lib/sportradar/api/data.rb in sportradar-api-0.9.35

- old
+ new

@@ -50,10 +50,14 @@ # @param data [Hash, Array] new data to update with def create_data(existing = {}, data, klass: nil, **opts) existing ||= {} # handles nil case, typically during object instantiation case data when Array - data.each { |hash| existing[hash['id']] = klass.new(hash, **opts) } + data.each do |hash| + current = existing[hash['id']] + current ? current.update(hash) : existing[hash['id']] = klass.new(hash, **opts) + existing[hash['id']] + end when Hash existing[data['id']] = klass.new(data, **opts) else # raise end