Class: DHS::Pagination::NextParameter

Inherits:
Base
  • Object
show all
Defined in:
lib/dhs/pagination/next_parameter.rb

Constant Summary collapse

DEFAULT_OFFSET =
nil

Constants inherited from Base

Base::DEFAULT_LIMIT

Instance Attribute Summary

Attributes inherited from Base

#data

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#current_page, #first_page, #initialize, #last_page, #limit, #limit_value, #next?, #next_offset, #next_page, #offset, page_to_offset, #pages_left, #prev_page, #previous?, #total_pages

Constructor Details

This class inherits a constructor from DHS::Pagination::Base

Class Method Details

.next_offset(_offset, _limit) ⇒ Object



12
13
14
# File 'lib/dhs/pagination/next_parameter.rb', line 12

def self.next_offset(_offset, _limit)
  nil
end

Instance Method Details

#next(current) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/dhs/pagination/next_parameter.rb', line 25

def next(current)
  next_value = current.dig(*_record.pagination_key(:body))
  return if next_value.blank?
  {
    _record.pagination_key(:parameter) => current.dig(*_record.pagination_key(:body))
  }
end

#pages_left?Boolean

Returns:

  • (Boolean)


20
21
22
23
# File 'lib/dhs/pagination/next_parameter.rb', line 20

def pages_left?
  next_offset = data._raw.dig(*_record.pagination_key(:body))
  next_offset.present? && !next_offset.blank?
end

#parallel?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/dhs/pagination/next_parameter.rb', line 16

def parallel?
  false
end

#totalObject Also known as: count



7
8
9
# File 'lib/dhs/pagination/next_parameter.rb', line 7

def total
  data._raw.dig(*_record.items_key).count || 0
end