Sha256: 9c8f90b0ee8a79ad5cd379ac0e7fc71c1276fe9e6289231d48996eddcea4a13b
Contents?: true
Size: 913 Bytes
Versions: 21
Compression:
Stored size: 913 Bytes
Contents
# frozen_string_literal: true require 'active_support' class LHS::Record module Pagination extend ActiveSupport::Concern # Kaminari-Interface delegate :current_page, :first_page, :last_page, :prev_page, :next_page, :limit_value, :total_pages, to: :_pagination def paginated?(raw = nil) self.class.paginated?(raw || _raw) end def _pagination self.class.pagination(_data) end module ClassMethods def pagination_class case pagination_strategy.to_sym when :page LHS::Pagination::Page when :start LHS::Pagination::Start else LHS::Pagination::Offset end end def pagination(data) pagination_class.new(data) end # Checks if given raw is paginated or not def paginated?(raw) !!(raw.is_a?(Hash) && raw.dig(*total_key)) end end end end
Version data entries
21 entries across 21 versions & 1 rubygems