Sha256: d09bd06054bce255d4d4c3c266edb1e2a1ed056d7699331aa813e2165bfdae1d

Contents?: true

Size: 651 Bytes

Versions: 4

Compression:

Stored size: 651 Bytes

Contents

module Algolia
  class ObjectIterator < BaseIterator
    # Custom each function to iterate through the objects
    #
    def each
      loop do
        data = {}

        if @response
          if @response[:hits].length
            @response[:hits].each do |hit|
              yield hit
            end

            if @response[:cursor].nil?
              @response = nil
              raise StopIteration
            else
              data[:cursor] = @response[:cursor]
            end
          end
        end
        @response = @transporter.read(:POST, path_encode('1/indexes/%s/browse', @index_name), data, @opts)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
algolia-2.0.0.pre.beta.1 lib/algolia/iterators/object_iterator.rb
algolia-2.0.0.pre.alpha.4 lib/algolia/iterators/object_iterator.rb
algolia-2.0.0.pre.alpha.3 lib/algolia/iterators/object_iterator.rb
algolia-2.0.0.pre.alpha.2 lib/algolia/iterators/object_iterator.rb