Module: Brapi::Resources::Paginated::ClassMethods
- Defined in:
- lib/brapi/resources/paginated.rb
Instance Method Summary collapse
Instance Method Details
#paginates(items:, via: :list, has_next: nil, next_page: nil, count_from: nil) ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'lib/brapi/resources/paginated.rb', line 58 def paginates(items:, via: :list, has_next: nil, next_page: nil, count_from: nil) has_next ||= ->(resp) { resp.pagination&.has_next_page } next_page ||= ->(resp) { (resp.pagination&.page || 0) + 1 } count_from ||= ->(resp) { resp.pagination&.total_items } define_each_page(via: via, has_next: has_next, next_page: next_page) define_each(items: items) define_count(via: via, count_from: count_from) end |