123456789_123456789_123456789_123456789_123456789_

Class: ActionView::StreamingTemplateRenderer::Body

Do not use. This class is for internal use only.
Relationships & Source Files
Inherits: Object
Defined in: actionview/lib/action_view/renderer/streaming_template_renderer.rb

Overview

A valid Rack::Body (i.e. it responds to each). It is initialized with a block that, when called, starts rendering the template.

Class Method Summary

Instance Method Summary

Constructor Details

.new(&start) ⇒ Body

[ GitHub ]

  
# File 'actionview/lib/action_view/renderer/streaming_template_renderer.rb', line 15

def initialize(&start)
  @start = start
end

Instance Method Details

#each(&block)

[ GitHub ]

  
# File 'actionview/lib/action_view/renderer/streaming_template_renderer.rb', line 19

def each(&block)
  begin
    @start.call(block)
  rescue Exception => exception
    log_error(exception)
    block.call ActionView::Base.streaming_completion_on_exception
  end
  self
end

#log_error(exception) (private)

This is the same logging logic as in ShowExceptions middleware.

[ GitHub ]

  
# File 'actionview/lib/action_view/renderer/streaming_template_renderer.rb', line 31

def log_error(exception)
  logger = ActionView::Base.logger
  return unless logger

  message = +"\n#{exception.class} (#{exception.message}):\n"
  message << exception.annotated_source_code.to_s if exception.respond_to?(:annotated_source_code)
  message << "  " << exception.backtrace.join("\n  ")
  logger.fatal("#{message}\n\n")
end