Module: OasRails::Extractors::RenderResponseExtractor

Defined in:
lib/oas_rails/extractors/render_response_extractor.rb

Overview

Extracts and processes render responses from a given source.

Class Method Summary collapse

Class Method Details

.extract_responses_from_source(specification, source:) ⇒ Array<Response>

Extracts responses from the provided source string.

Parameters:

  • source (String)

    The source string containing render calls.

Returns:

  • (Array<Response>)

    An array of Response objects extracted from the source.



10
11
12
13
14
15
# File 'lib/oas_rails/extractors/render_response_extractor.rb', line 10

def extract_responses_from_source(specification, source:)
  render_calls = extract_render_calls(source)
  return [Builders::ResponseBuilder.new(specification).with_description("No content").with_code(204).build] if render_calls.empty?

  render_calls.map { |render_content, status| process_render_content(specification, render_content.strip, status) }
end