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-2.6.0 lib/ledger_sync/ledgers/mixins/offset_and_limit_pagination_searcher_mixin.rb
ledger_sync-2.5.0 lib/ledger_sync/ledgers/mixins/offset_and_limit_pagination_searcher_mixin.rb
ledger_sync-2.4.4 lib/ledger_sync/ledgers/mixins/offset_and_limit_pagination_searcher_mixin.rb
ledger_sync-2.3.1 lib/ledger_sync/ledgers/mixins/offset_and_limit_pagination_searcher_mixin.rb
ledger_sync-2.2.3 lib/ledger_sync/ledgers/mixins/offset_and_limit_pagination_searcher_mixin.rb
ledger_sync-2.2.1 lib/ledger_sync/ledgers/mixins/offset_and_limit_pagination_searcher_mixin.rb
ledger_sync-2.2.0 lib/ledger_sync/ledgers/mixins/offset_and_limit_pagination_searcher_mixin.rb
ledger_sync-2.0.2 lib/ledger_sync/ledgers/mixins/offset_and_limit_pagination_searcher_mixin.rb
ledger_sync-2.0.1 lib/ledger_sync/ledgers/mixins/offset_and_limit_pagination_searcher_mixin.rb
ledger_sync-2.0.0 lib/ledger_sync/ledgers/mixins/offset_and_limit_pagination_searcher_mixin.rb
ledger_sync-2.0.0.pre.1 lib/ledger_sync/ledgers/mixins/offset_and_limit_pagination_searcher_mixin.rb
ledger_sync-1.8.1 lib/ledger_sync/ledgers/mixins/offset_and_limit_pagination_searcher_mixin.rb
ledger_sync-1.8.0 lib/ledger_sync/ledgers/mixins/offset_and_limit_pagination_searcher_mixin.rb
ledger_sync-1.7.0 lib/ledger_sync/ledgers/mixins/offset_and_limit_pagination_searcher_mixin.rb
ledger_sync-1.6.0 lib/ledger_sync/ledgers/mixins/offset_and_limit_pagination_searcher_mixin.rb
ledger_sync-1.5.2 lib/ledger_sync/ledgers/mixins/offset_and_limit_pagination_searcher_mixin.rb
ledger_sync-1.5.1 lib/ledger_sync/ledgers/mixins/offset_and_limit_pagination_searcher_mixin.rb
ledger_sync-1.5.0 lib/ledger_sync/ledgers/mixins/offset_and_limit_pagination_searcher_mixin.rb
ledger_sync-1.4.4 lib/ledger_sync/ledgers/mixins/offset_and_limit_pagination_searcher_mixin.rb
ledger_sync-1.4.2 lib/ledger_sync/ledgers/mixins/offset_and_limit_pagination_searcher_mixin.rb