Class: WCC::Contentful::SimpleClient::PaginatingEnumerable

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/wcc/contentful/simple_client/response.rb

Instance Method Summary collapse

Constructor Details

#initialize(initial_page) ⇒ PaginatingEnumerable

Returns a new instance of PaginatingEnumerable.

Raises:

  • (ArgumentError)


177
178
179
180
181
# File 'lib/wcc/contentful/simple_client/response.rb', line 177

def initialize(initial_page)
  raise ArgumentError, 'Must provide initial page' unless initial_page.present?

  @initial_page = initial_page
end

Instance Method Details

#each {|page| ... } ⇒ Object

Yields:

  • (page)


183
184
185
186
187
188
189
190
191
# File 'lib/wcc/contentful/simple_client/response.rb', line 183

def each
  page = @initial_page
  yield page

  while page.next_page?
    page = page.next_page
    yield page
  end
end