Sha256: 34616e444d114808e6a069bde42b7470cd0459205b9f3f9f9dda607e5c87707a

Contents?: true

Size: 390 Bytes

Versions: 2

Compression:

Stored size: 390 Bytes

Contents

# frozen_string_literal: true

require_relative './page_size_for_helper'

module Pagination
  module TotalPagesForHelper
    include Pagination::PageSizeForHelper

    def pagination_total_pages_for(set)
      total_set_size = set.instructions.dig(:paginate, :count)
      return 1 if total_set_size.zero?

      (total_set_size.to_f / pagination_page_size_for(set)).ceil
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
actionset-0.8.2 lib/action_set/helpers/pagination/total_pages_for_helper.rb
actionset-0.8.1 lib/action_set/helpers/pagination/total_pages_for_helper.rb