Sha256: 851f8c05003c1cbb7ca5f821bc61cdb32e607713a91e07a631acb27ae3f2de78

Contents?: true

Size: 585 Bytes

Versions: 2

Compression:

Stored size: 585 Bytes

Contents

module PaginateResponder::Adapter

  # Pagination adapter for will_paginate.
  #
  class PaginateAdapter < Base

    def suitable?
      defined?(:WillPaginate) and resource.respond_to?(:paginate)
    end

    def paginate(opts)
      resource.paginate :page => opts[:page], :per_page => opts[:per_page]
    end

    def defaults
      { :per_page => 50, :max_per_page => 50 }
    end

    def total_pages
      resource.total_pages if resource.respond_to? :total_pages
    end

    def total_count
      resource.total_entries if resource.respond_to? :total_entries
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
paginate-responder-1.4.1 lib/paginate-responder/adapter/paginate_adapter.rb
paginate-responder-1.4.0 lib/paginate-responder/adapter/paginate_adapter.rb