Sha256: 3c258068231aa6fdb8d3d18d11cf10496ecf1101ccb1dc6c91559fe3bd0fa59c

Contents?: true

Size: 765 Bytes

Versions: 1

Compression:

Stored size: 765 Bytes

Contents

# frozen_string_literal: true

module Archangel
  ##
  # Controller concerns
  #
  module Controllers
    ##
    # 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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
archangel-0.4.0 app/controllers/concerns/archangel/controllers/paginatable_concern.rb