module AWS::Core::Collection::Simple

def _each_item options = {}, &block

def _each_item options = {}, &block
  raise NotImplementedError
end

def each_batch options = {}, &block

(see AWS::Core::Collection#each_batch)
def each_batch options = {}, &block
  each_opts  = options.dup
  limit      = each_opts.delete(:limit)
  next_token = each_opts.delete(:next_token)
  offset     = next_token ? next_token.to_i - 1 : 0
  total      = 0
  nil_or_next_token = nil
  batch = []
  _each_item(each_opts.dup) do |item|
    total += 1
    # skip until we reach our offset (derived from the "next token")
    next if total <= offset
    if limit
      if batch.size < limit
        batch << item
      else
        # allow _each_item to yield one more item than needed
        # so we can determine if we should return a "next token"
        nil_or_next_token = total
        break
      end
    else
      batch << item
    end
  end
  yield(batch)
  nil_or_next_token
end