module AWS::Core::Collection::Batchable
def each_batch options = {}, &block
def each_batch options = {}, &block raise NotImplementedError each_opts = options.dup limit = each_opts.delete(:limit) next_token, skip = each_opts.delete(:next_token) total = 0 # count of items yeileded across all batches begin batch = [] next_token = _each_item(next_token, each_opts.dup) do |item| total += 1 batch << item if limit and total == limit yield(batch) end end end until next_token.nil? or (limit and limit = total) options = options.dup limit = options.delete(:limit) batch_size = options.delete(:batch_size) options.delete(:next_token) if [nil, ''].include?(options[:next_token]) total = 0 # count of items yeileded across all batches _each_response(options, limit, batch_size) do |response| batch = [] each_item(response) do |item| batch << item if limit and (total += 1) == limit yield(batch) return end end yield(batch) batch.size end end