Class: Gapic::Presenters::SnippetPresenter::PaginatedResponseHandlingPresenter

Inherits:
Object
  • Object
show all
Includes:
ResponseHandlingPresenterCommon
Defined in:
lib/gapic/presenters/snippet/response_handling_presenters.rb

Overview

Presentation information about paginated response handling

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(proto, json, paged_response_type:, phase1:) ⇒ PaginatedResponseHandlingPresenter

Create a paginated response handling presenter

Parameters:

  • proto (Google::Cloud::Tools::SnippetGen::ConfigLanguage::V1::Snippet::PaginatedResponseHandling)

    The protobuf representation

  • json (String)

    The JSON representation

  • paged_response_type (String)

    The fully qualified message class for individual responses

  • phase1 (Boolean)

    True if this is a phase 1 snippet without config



247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
# File 'lib/gapic/presenters/snippet/response_handling_presenters.rb', line 247

def initialize proto, json, paged_response_type:, phase1:
  @response_name = compute_response_name proto, phase1
  @render_lines = []
  if @response_name
    if phase1
      @render_lines << "# The returned object is of type Gapic::PagedEnumerable. You can iterate"
      @render_lines << "# over elements, and API calls will be issued to fetch pages as needed."
    end
    @render_lines +=
      if proto&.by_page
        by_page_lines proto, json, @response_name, paged_response_type, phase1
      elsif proto&.next_page_token
        next_page_token_lines proto, json
      else
        by_item_lines proto, json, @response_name, paged_response_type, phase1
      end
  end
  @render = @render_lines.join "\n"
end

Instance Attribute Details

#renderString (readonly)

The rendered code as a single string, possibly with line breaks

Returns:

  • (String)


277
278
279
# File 'lib/gapic/presenters/snippet/response_handling_presenters.rb', line 277

def render
  @render
end

#render_linesArray<String> (readonly)

The lines of rendered code

Returns:

  • (Array<String>)


271
272
273
# File 'lib/gapic/presenters/snippet/response_handling_presenters.rb', line 271

def render_lines
  @render_lines
end

#response_nameString? (readonly)

The name of the response variable, or nil for no response handling

Returns:

  • (String, nil)


283
284
285
# File 'lib/gapic/presenters/snippet/response_handling_presenters.rb', line 283

def response_name
  @response_name
end