Sha256: 0ea08a071408d53a70e00e61f83dc1e65eb11962bed4ff9e301a8643cf6e4070

Contents?: true

Size: 714 Bytes

Versions: 9

Compression:

Stored size: 714 Bytes

Contents

# frozen_string_literal: true

module RatingChgkV2
  module Concerns
    module Paginated
      def next_page!
        page_num = current_page + 1
        params = endpoint.params.merge({page: page_num})
        endpoint.reinitialize new_params: params
        setup endpoint.do_get, endpoint
        self
      end

      def prev_page!
        return if current_page <= 1

        page_num = current_page - 1
        params = endpoint.params.merge({page: page_num})
        endpoint.reinitialize new_params: params
        setup endpoint.do_get, endpoint
        self
      end

      private

      def current_page
        endpoint.params[:page] || 1
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rating-chgk-v2-1.6.0 lib/rating_chgk_v2/concerns/paginated.rb
rating-chgk-v2-1.5.0 lib/rating_chgk_v2/concerns/paginated.rb
rating-chgk-v2-1.4.0 lib/rating_chgk_v2/concerns/paginated.rb
rating-chgk-v2-1.3.0 lib/rating_chgk_v2/concerns/paginated.rb
rating-chgk-v2-1.2.0 lib/rating_chgk_v2/concerns/paginated.rb
rating-chgk-v2-1.1.0 lib/rating_chgk_v2/concerns/paginated.rb
rating-chgk-v2-1.0.1 lib/rating_chgk_v2/concerns/paginated.rb
rating-chgk-v2-1.0.0 lib/rating_chgk_v2/concerns/paginated.rb
rating-chgk-v2-1.0.0.rc1 lib/rating_chgk_v2/concerns/paginated.rb