Class: FinchAPI::Internal::SinglePage
- Inherits:
-
Array
- Object
- Array
- FinchAPI::Internal::SinglePage
- Includes:
- Type::BasePage
- Defined in:
- lib/finch_api/internal/single_page.rb
Overview
Instance Method Summary collapse
- #auto_paging_each(&blk) {|| ... } ⇒ Object
-
#initialize(client:, req:, headers:, page_data:) ⇒ SinglePage
constructor
private
A new instance of SinglePage.
- #inspect ⇒ String private
- #next_page ⇒ self
- #next_page? ⇒ Boolean
Methods included from Type::BasePage
Constructor Details
#initialize(client:, req:, headers:, page_data:) ⇒ SinglePage
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of SinglePage.
53 54 55 56 57 58 59 60 61 |
# File 'lib/finch_api/internal/single_page.rb', line 53 def initialize(client:, req:, headers:, page_data:) super case page_data in Array replace(page_data.map { FinchAPI::Internal::Type::Converter.coerce(@model, _1) }) else end end |
Instance Method Details
#auto_paging_each(&blk) {|| ... } ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/finch_api/internal/single_page.rb', line 33 def auto_paging_each(&blk) unless block_given? raise ArgumentError.new("A block must be given to ##{__method__}") end page = self loop do page.each(&blk) break unless page.next_page? page = page.next_page end end |
#inspect ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
66 67 68 69 70 |
# File 'lib/finch_api/internal/single_page.rb', line 66 def inspect model = FinchAPI::Internal::Type::Converter.inspect(@model, depth: 1) "#<#{self.class}[#{model}]:0x#{object_id.to_s(16)}>" end |
#next_page ⇒ self
26 27 28 |
# File 'lib/finch_api/internal/single_page.rb', line 26 def next_page RuntimeError.new("No more pages available.") end |
#next_page? ⇒ Boolean
20 21 22 |
# File 'lib/finch_api/internal/single_page.rb', line 20 def next_page? false end |