Module: PaypalAPI::Response::PaginationHelpers
- Included in:
- PaypalAPI::Response
- Defined in:
- lib/paypal-api/response.rb
Overview
Pagination methods
Instance Method Summary collapse
-
#each_page {|Response| ... } ⇒ void
Iterates through all response pages by requesting HATEOAS “next” links, making additional fetches to the API as necessary.
-
#each_page_item(items_field_name) {|Hash| ... } ⇒ void
Iterates through all items in response
items_field_namefield, making additional pages requests as necessary.
Instance Method Details
#each_page {|Response| ... } ⇒ void
This method returns an undefined value.
Iterates through all response pages by requesting HATEOAS “next” links, making additional fetches to the API as necessary.
148 149 150 151 152 153 154 |
# File 'lib/paypal-api/response.rb', line 148 def each_page(&block) return enum_for(:each_page) unless block page = self yield(page) yield(page) while (page = page.follow_up_link("next")) end |
#each_page_item(items_field_name) {|Hash| ... } ⇒ void
This method returns an undefined value.
Iterates through all items in response items_field_name field, making additional pages requests as necessary.
168 169 170 171 172 173 174 |
# File 'lib/paypal-api/response.rb', line 168 def each_page_item(items_field_name, &block) return enum_for(:each_page_item, items_field_name) unless block each_page do |page| page.fetch(items_field_name).each(&block) end end |