Iterates through each resource in all pages, making additional fetches to
 the API as necessary.

 Note that this method will make as many API calls as necessary to fetch
 all resources. For more granular control, please see +each+ and
 +next_page+.
426221
def auto_paging_each(&blk)
      return enum_for(:auto_paging_each) unless block_given?

      page = self
      loop do
        page.each(&blk)
        page = page.next_page
        break if page.empty?
      end
    end
1071482
def all(self, endpoint, *args, **kwargs):
        
        # 1. Initialize the pagination parameters.
        kwargs.setdefault('params', {})['offset'] = 0
        kwargs.setdefault('params', {})['limit'] = self.limit
        kwargs['__method__'] = 'get'
        # 2. Create an initial paginated request.
        payload = self.request(endpoint, *args, **kwargs)
        has_next = payload.get('result', {}).setdefault(
            'meta', {'next': None}
        )['next']
        # 3. Loop until the end
        while has_next:
            # 4. Increment the offset
            kwargs['params']['offset'] += self.limit
            # 5. Query again
            _payload = self.request(endpoint, *args, **kwargs)
            # 6. Add the paginated data to the global one
            payload['result']['data'].extend(_payload['result']['data'])
            # 7. Compute has_next
            has_next = _payload['result']['meta']['next']
        del payload['result']['meta']
        return payload
589963
def _iterate_through_pages(get_function, resource, **kwargs):
        

        request_data = True
        data = []
        page = 1

        while request_data:
            temp_response = get_function(page=page, **kwargs)
            if temp_response[resource]['@total'] != '0':
                data.append(temp_response)

            page += 1
            if page > int(
                math.ceil(
                    float(temp_response[resource]['@total']) / float(temp_response[resource]['@per_page'])
                )
            ):
                request_data = False
        return data
1154201
function pages(req, res, next) {

    generator.getPage(req.url, function(err, page) {

      if (err || !page || !checkMethod(req, page)) return next();

      if (!isPageAuthorized(req, page)) {
        if (!server.login || page.nologin) return next();
        return server.login(req, res);
      }

      debug('page %s', page._href);

      // make req and res available to dynamic pages
      generator.req = req;
      generator.res = res;

      resHeaders(res, page);
      res.send(generator.renderDoc(page));

    });
  }
642060
def each_url(&_block)
      index = 0
      while index < urls.count # urls grows dynamically, don't use &:each
        url = urls[index]
        next unless url
        yield url, handlers[url].first, handlers[url].last
        index += 1
      end
    end
628380
def each
      @raw_page['records'].each { |record| yield Restforce::Mash.build(record, @client) }

      np = next_page
      while np
        np.current_page.each { |record| yield record }
        np = np.next_page
      end
    end
771244
def each_resource(&block)
      Enumerator.new do |result|
        each_page { |resources| resources.each { |resource| result << resource } }
      end.each(&block)
    end
738271
def each(&block)
      return enum_for(:each_page) unless block_given?
      response = self
      yield(response)
      until response.last_page?
        response = response.next_page
        yield(response)
      end
    end
685319
function(callback){
    var self = this;

    // if we have no pages just fire callback
    if(self.pageCollection.length === 0){
      callback(self);
    }

    // this is called once a page is fully parsed
    whenPageIsFetched = function(){
      self.completed ++;
      if(self.completed === self.pageCollection.length){
        callback(self);
      } else {
        findUnfetchedPages();
      }  
    }

    findUnfetchedPages = function(){ 
      _.each(self.pageCollection, function (page) {
        if (page.status === "unfetched") {
          page.fetch(whenPageIsFetched);
        }
      });
    },

    findUnfetchedPages();
  }
101564
def get_all_results(starting_page):
    
    logging.info('Retrieving all results for {}'.format(starting_page))
    page = starting_page
    results = []

    while True:
        logging.debug('Getting data from: {}'.format(page))
        data = get_page(page)
        logging.debug('JSON data: {}'.format(data))
        results = results + data['results']

        if data['next']:
            page = data['next']
        else:
            break

    return results
1049553
def fetch_pages(url, referer = nil, depth = nil)
      begin
        url = URI(url) unless url.is_a?(URI)
        pages = []
        get(url, referer) do |response, code, location, redirect_to, response_time|
          pages << Page.new(location, :body => response.body.dup,
                                      :code => code,
                                      :headers => response.to_hash,
                                      :referer => referer,
                                      :depth => depth,
                                      :redirect_to => redirect_to,
                                      :response_time => response_time)
        end

        return pages
      rescue Exception => e
        if verbose?
          puts e.inspect
          puts e.backtrace
        end
        return [Page.new(url, :error => e)]
      end
    end
233962
public function iteratePages()
    {
        $currentPage = $this;
        yield $this;
        while ($currentPage->hasNextPage()) {
            $currentPage = $currentPage->getNextPage();
            yield $currentPage;
        }
    }
800959
def get_all_articles(self, params=None):
        
        if not params:
            params = {}
        return self._iterate_through_pages(self.get_articles_per_page, resource=ARTICLES, **{'params': params})
157661
def fetch(reload = false, query_params = {})
      return if expanded? && !reload
      response = client.get(url_with_query_params(url, query_params))
      set_attrs_from_response(response)
      @expanded = true
    end
1071278
def autopage(self):
        
        while self.items:
            yield from self.items
            self.items = self.fetch_next()
1261929
def all(page = 1, limit = 100, latest = true)
      opts = connection.version == 2 ? {:unseen => latest} : {:latest => latest}
      connection.get(resource_uri, {:query => {:limit => limit, :page => page}.merge(opts)})
    end
501912
def _call_api_many_related_resources(self, resource, url_list,
                                         method_name, **kwargs):
        
        responses = []
        for url in url_list:
            params = {
                'headers': self.get_http_headers(
                    resource.Meta.name, method_name, **kwargs),
                'url': url
            }
            prepared_request = self.prepare_http_request(
                'GET', params, **kwargs)
            response = self.session.send(prepared_request)
            result = self._handle_response(
                response, resource.Meta.valid_status_codes, resource)
            if len(result) > 1:
                responses.append(result)
            else:
                responses.append(result[0])
        return responses