lib/google/cloud/pubsub/snapshot/list.rb in google-cloud-pubsub-2.3.2 vs lib/google/cloud/pubsub/snapshot/list.rb in google-cloud-pubsub-2.4.0

- old
+ new

@@ -123,15 +123,15 @@ # snapshots = pubsub.snapshots # snapshots.all(request_limit: 10) do |snapshot| # puts snapshot.name # end # - def all request_limit: nil + def all request_limit: nil, &block request_limit = request_limit.to_i if request_limit return enum_for :all, request_limit: request_limit unless block_given? results = self loop do - results.each { |r| yield r } + results.each(&block) if request_limit request_limit -= 1 break if request_limit.negative? end break unless results.next?