Sha256: 512fa6d50696b0d2f2a561c28730b0acff52f4070fa8760c8891ca918e2530cc

Contents?: true

Size: 554 Bytes

Versions: 1

Compression:

Stored size: 554 Bytes

Contents

# frozen_string_literal: true

module Kentaa
  module Api
    module Requests
      module All
        def all(options = {})
          enumerator = Enumerator.new do |yielder|
            page = 1

            loop do
              response = list(options.merge(page: page))
              response.each { |item| yielder.yield item } if response.success?

              raise StopIteration unless response.next_page?

              page = response.next_page
            end
          end

          enumerator.lazy
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kentaa-api-0.1.1 lib/kentaa/api/requests/all.rb