Sha256: ccdc0866347b18f1596b72fff7558184a2c3dbd88c6478dd651cb0b137967347

Contents?: true

Size: 715 Bytes

Versions: 22

Compression:

Stored size: 715 Bytes

Contents

# frozen_string_literal: true

module LedgerSync
  module Ledgers
    module Mixins
      module OffsetAndLimitPaginationSearcherMixin
        def next_searcher
          paginate(limit: limit, offset: offset + limit)
        end

        def previous_searcher
          return nil if offset <= 1

          paginate(limit: limit, offset: offset - limit)
        end

        private

        def default_offset
          raise NotImplementedError
        end

        def default_limit
          10
        end

        def limit
          pagination.fetch(:limit, default_limit).to_i
        end

        def offset
          pagination.fetch(:offset, default_offset).to_i
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
ledger_sync-1.4.1 lib/ledger_sync/ledgers/mixins/offset_and_limit_pagination_searcher_mixin.rb
ledger_sync-1.4.0 lib/ledger_sync/ledgers/mixins/offset_and_limit_pagination_searcher_mixin.rb