Sha256: 938c26ae88474e997c1b01bd9285ea8023279554f4f8391e7258f35f6fbf528e

Contents?: true

Size: 621 Bytes

Versions: 7

Compression:

Stored size: 621 Bytes

Contents

# frozen_string_literal: true

module Archangel
  ##
  # Controller pagination concern
  #
  module PaginatableConcern
    extend ActiveSupport::Concern

    included do
      helper_method :page_num, :per_page
    end

    # Record limt count
    #
    # @return [Integer] the record count limit
    def per_page
      params.fetch(:per, per_page_default).to_i
    end

    # Current page number
    #
    # @return [Integer] the page number
    def page_num
      params.fetch(Kaminari.config.param_name, 1).to_i
    end

    protected

    def per_page_default
      Kaminari.config.default_per_page
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
archangel-0.0.8 app/controllers/concerns/archangel/paginatable_concern.rb
archangel-0.0.7 app/controllers/concerns/archangel/paginatable_concern.rb
archangel-0.0.6 app/controllers/concerns/archangel/paginatable_concern.rb
archangel-0.0.5 app/controllers/concerns/archangel/paginatable_concern.rb
archangel-0.0.4 app/controllers/concerns/archangel/paginatable_concern.rb
archangel-0.0.3 app/controllers/concerns/archangel/paginatable_concern.rb
archangel-0.0.2 app/controllers/concerns/archangel/paginatable_concern.rb