Sha256: 105de3969a0752b7a80e84e23a1612a3d55089c90b12eb271037dc199483d39e

Contents?: true

Size: 748 Bytes

Versions: 3

Compression:

Stored size: 748 Bytes

Contents

module PaginateResponder::Adapter
  class Base
    attr_reader :resource

    def initialize(resource)
      @resource = resource
    end

    def paginate!(opts)
      @resource = paginate(opts)
    end

    # If pagination for current resource is supported.
    #
    def suitable?
      false
    end

    # Return paginated resource.
    # Option hash will contain at least <tt>:per_page</tt>
    # and <tt>:page</tt>.
    #
    def paginate(opts)
      resource
    end

    # Return number of total pages for current resource.
    #
    def total_pages
      nil
    end

    # Return default values for items per page and maximum
    # items per page.
    #
    def defaults
      { :per_page => 50, :max_per_page => 100 }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
paginate-responder-1.4.0 lib/paginate-responder/adapter/base.rb
paginate-responder-1.3.0 lib/paginate-responder/adapter/base.rb
paginate-responder-1.2.0 lib/paginate-responder/adapter/base.rb