Sha256: 9047ec229506ee3e88e8149acac681645d5c5740fb6f149f627ce3e8e949cdb9

Contents?: true

Size: 689 Bytes

Versions: 27

Compression:

Stored size: 689 Bytes

Contents

module Highrise
  module Pagination
    def self.included(base)
      base.extend(ClassMethods)
    end

    module ClassMethods
      def find_all_across_pages(options = {})
        records = []
        each(options) { |record| records << record }
        records
      end

      def each(options = {})
        options[:params] ||= {}
        options[:params][:n] = 0

        loop do
          if (records = self.find(:all, options)).any?
            records.each { |record| yield record }
            options[:params][:n] += records.size
          else
            break # no people included on that page, thus no more people total
          end
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 6 rubygems

Version Path
kmayer-highrise-0.11.0 lib/highrise/pagination.rb
kmayer-highrise-0.11.1 lib/highrise/pagination.rb
kmayer-highrise-0.12.0 lib/highrise/pagination.rb
kmayer-highrise-0.13.0 lib/highrise/pagination.rb
kmayer-highrise-0.7.0 lib/highrise/pagination.rb
kmayer-highrise-0.7.1 lib/highrise/pagination.rb
kmayer-highrise-0.8.0 lib/highrise/pagination.rb
kmayer-highrise-0.8.1 lib/highrise/pagination.rb
kmayer-highrise-0.9.0 lib/highrise/pagination.rb
kmayer-highrise-0.9.1 lib/highrise/pagination.rb
kmayer-highrise-0.9.2 lib/highrise/pagination.rb
kmayer-highrise-1.0.1 lib/highrise/pagination.rb
slainer68-highrise-0.6.1 lib/highrise/pagination.rb
slainer68-highrise-0.6.2 lib/highrise/pagination.rb
slainer68-highrise-0.6 lib/highrise/pagination.rb
tapajos-highrise-0.6 lib/highrise/pagination.rb
tapajos-highrise-0.8.0 lib/highrise/pagination.rb
rogerio-augusto-highrise-2.0.4 lib/highrise/pagination.rb
rogerio-augusto-highrise-2.0.3 lib/highrise/pagination.rb
rogerio-augusto-highrise-2.0.2 lib/highrise/pagination.rb