class Gapic::Rest::PagedEnumerable::Page
@return [Object] the response object for the page.
@attribute [r] response
resource elements.
A class to represent a page in a PagedEnumerable. This also implements Enumerable, so it can iterate over the
#
def each
-
(Enumerator)
- if no block is provided
Other tags:
- Yield: - Gives the resource objects in the page.
def each return enum_for :each unless block_given? # We trust that the field exists and is an Enumerable resources.each do |resource| resource = @format_resource.call resource if @format_resource yield resource end end
def initialize response, resource_field, format_resource: nil
-
format_resource
(Proc, nil
) -- A Proc object to format the resource object. Default nil (no formatting). -
resource_field
(String
) -- The name of the field in response which holds the resources. -
response
(Object
) -- The response object for the page.
Other tags:
- Private: -
def initialize response, resource_field, format_resource: nil @response = response @resource_field = resource_field @format_resource = format_resource end
def next_page_token
-
(String)
-
def next_page_token @response.next_page_token end
def next_page_token?
-
(Boolean)
-
def next_page_token? !next_page_token.empty? end
def resources
-
(Array)
-
def resources @resources ||= @response[@resource_field].to_a end