Sha256: f4505836fb958b0135cf144fd670e07e2a86dcc318084731f58ea83213a1e7d1

Contents?: true

Size: 532 Bytes

Versions: 3

Compression:

Stored size: 532 Bytes

Contents

# frozen_string_literal: true

module Kentaa
  module Api
    module Clients
      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 }

              raise StopIteration unless response.next_page?

              page = response.next_page
            end
          end

          enumerator.lazy
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kentaa-api-0.3.2 lib/kentaa/api/clients/all.rb
kentaa-api-0.3.1 lib/kentaa/api/clients/all.rb
kentaa-api-0.3.0 lib/kentaa/api/clients/all.rb