SimplePagination

A simple Ruby module which encapsulates general purpose pagination logic. This won’t limit your database queries or cook pancakes for you, but it will save you from rewriting pagination code all over the place.

There are already some great pagination libraries for Rails/ActiveRecord which limit database queries etc (see github.com/mislav/will_paginate). The goal here is to provide generic pagination logic for times when a full-stack library would be inappropriate or just overkill – for example, when paginating results from calls to a remote API.

Basic Usage

require 'rubygems'
require 'simple_pagination'

class MyResultSet
  include SimplePagination
  def pages
    PageCollection.new(:current_page => 1, :page_size => 10, :total => 59389)
  end
end

See SimplePagination::PageCollection for more info.

Copyright © 2009 Taylor Barstow. This code is licensed under the MIT license.

See the LICENSE file for details.