Sha256: fb0f904186732f9d4cb0a293825181299345e8c8ae4b1b7321e8a23bbe0236b0

Contents?: true

Size: 389 Bytes

Versions: 3

Compression:

Stored size: 389 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 == 0

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
actionset-0.8.0 lib/action_set/helpers/pagination/total_pages_for_helper.rb
actionset-0.7.0 lib/action_set/helpers/pagination/total_pages_for_helper.rb
actionset-0.6.0 lib/action_set/helpers/pagination/total_pages_for_helper.rb