Sha256: 227b8b9e393407b65e1f2e3b4e44e0022e4a5ba76de011d6b3c1addaee66c716

Contents?: true

Size: 508 Bytes

Versions: 1

Compression:

Stored size: 508 Bytes

Contents

module PaginateResponder::Adapter

  # Pagination adapter for kaminari.
  #
  class KaminariAdapter < Base

    def suitable?
      resource.respond_to?(:page)
    end

    def paginate(opts)
      resource.page(opts[:page]).per(opts[:per_page])
    end

    def defaults
      {
          :per_page => Kaminari.config.default_per_page,
          :max_per_page => Kaminari.config.max_per_page
      }
    end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
paginate-responder-1.2.0 lib/paginate-responder/adapter/kaminari_adapter.rb