Sha256: a5ba3d5f4548560a44abc0af88ec1dd4b5d855e448ac8c1927318b34adc18494

Contents?: true

Size: 829 Bytes

Versions: 4

Compression:

Stored size: 829 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 number of total items.
    #
    def total_count
      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

4 entries across 4 versions & 1 rubygems

Version Path
paginate-responder-1.5.0 lib/paginate-responder/adapter/base.rb
paginate-responder-1.4.2 lib/paginate-responder/adapter/base.rb
paginate-responder-1.4.2.beta0 lib/paginate-responder/adapter/base.rb
paginate-responder-1.4.1 lib/paginate-responder/adapter/base.rb