Class: DHS::Pagination::NextOffset
- Inherits:
-
Base
- Object
- Base
- DHS::Pagination::NextOffset
show all
- Defined in:
- lib/dhs/pagination/next_offset.rb
Constant Summary
collapse
- DEFAULT_OFFSET =
0
Constants inherited
from Base
Base::DEFAULT_LIMIT
Instance Attribute Summary
Attributes inherited from Base
#data
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
Instance Method Details
#next(current) ⇒ Object
21
22
23
24
25
26
27
|
# File 'lib/dhs/pagination/next_offset.rb', line 21
def next(current)
next_value = current.dig(*_record.(:body))
return if next_value.blank? || next_value.zero?
{
_record.(:parameter) => current.dig(*_record.(:body))
}
end
|
#pages_left? ⇒ Boolean
16
17
18
19
|
# File 'lib/dhs/pagination/next_offset.rb', line 16
def pages_left?
next_offset = data._raw.dig(*_record.(:body))
next_offset.present? && !next_offset.zero?
end
|
#parallel? ⇒ Boolean
12
13
14
|
# File 'lib/dhs/pagination/next_offset.rb', line 12
def parallel?
false
end
|
#total ⇒ Object
Also known as:
count
7
8
9
|
# File 'lib/dhs/pagination/next_offset.rb', line 7
def total
data._raw.dig(*_record.items_key).count || 0
end
|