# File lib/aws/dynamo_db/item_collection.rb, line 586 def count options = {} options = options.merge(:count => true) # since each with :count yields the per-page counts, each with # :limit and :count effectively limits the number of requests, # not the number of items limit = options.delete(:limit) options[:limit] = options.delete(:max_requests) if options.key?(:max_requests) # it usually doesn't make sense to ask for more items than you # care about counting options[:batch_size] ||= limit if limit enumerator(options).inject(0) do |sum, n| return limit if limit && sum + n >= limit sum + n end end