# File lib/aws/collections.rb, line 191 def each_response options, limit, batch_size, &block total = 0 next_token = nil begin page_opts = {} page_opts[next_token_key] = next_token if next_token if limit or batch_size max_items = [] max_items << (limit - total) if limit max_items << batch_size if batch_size page_opts[limit_key] = max_items.min end response = client.send(request_method, options.merge(page_opts)) total += yield(response) next_token = next_token_for(response) end until next_token.nil? or (limit and limit == total) end