Sha256: a63824a3d16b7e0c9a765e5373f0d93eef2b0ef9aa0e6135e925878813fcd919

Contents?: true

Size: 837 Bytes

Versions: 4

Compression:

Stored size: 837 Bytes

Contents

module ApiResource

  module Conditions

    #
    # Class to handle pagination params, passing
    # of pagination params along to the server, and the
    # retrieval of the headers from the response
    #
    # @author [dlangevin]
    #
    class PaginationCondition < AbstractCondition

      #
      # Constructor - sets up the pagination options
      # @param  opts = {} [Hash] Pagination opts
      # @option opts [Fixnum] :page (1) Page we are on
      # @option opts [Fixnum] :per_page (10) Number per page
      def initialize(klass, opts = {})
        @page = opts[:page] || 1
        @per_page = opts[:per_page] || 10
        super({ page: @page, per_page: @per_page }, klass)
      end

      #
      # Are we paginated?
      #
      # @return [Boolean] true
      def paginated?
        true
      end

    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
api_resource-0.6.25 lib/api_resource/conditions/pagination_condition.rb
api_resource-0.6.24 lib/api_resource/conditions/pagination_condition.rb
api_resource-0.6.23 lib/api_resource/conditions/pagination_condition.rb
api_resource-0.6.22 lib/api_resource/conditions/pagination_condition.rb