rakuten-ws/rws-ruby-sdk

View on GitHub
lib/rakuten_web_service/all_proxy.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
# frozen_string_literal: true

module RakutenWebService
  class AllProxy
    include Enumerable

    def initialize(search_result)
      @search_result = search_result
    end

    def each
      search_result = @search_result
      loop do
        search_result.each do |resource|
          yield resource
        end
        break unless search_result.has_next_page?
        search_result = search_result.next_page
      end
    end
  end
end