From af2129b4c74732c88ffce76e5c55c805cb9431f6 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Thu, 1 Aug 2019 16:41:26 +0900 Subject: Use `try` only when we're unsure if the receiver would respond_to the method --- actionview/lib/action_view/renderer/streaming_template_renderer.rb | 2 +- actionview/lib/action_view/renderer/template_renderer.rb | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'actionview/lib/action_view/renderer') diff --git a/actionview/lib/action_view/renderer/streaming_template_renderer.rb b/actionview/lib/action_view/renderer/streaming_template_renderer.rb index 08a280c7ee..5942717b8d 100644 --- a/actionview/lib/action_view/renderer/streaming_template_renderer.rb +++ b/actionview/lib/action_view/renderer/streaming_template_renderer.rb @@ -62,7 +62,7 @@ module ActionView output = ActionView::StreamingBuffer.new(buffer) yielder = lambda { |*name| view._layout_for(*name) } - instrument(:template, identifier: template.identifier, layout: layout.try(:virtual_path)) do + instrument(:template, identifier: template.identifier, layout: (layout && layout.virtual_path)) do outer_config = I18n.config fiber = Fiber.new do I18n.config = outer_config diff --git a/actionview/lib/action_view/renderer/template_renderer.rb b/actionview/lib/action_view/renderer/template_renderer.rb index b2d7332572..da0b2dc0d2 100644 --- a/actionview/lib/action_view/renderer/template_renderer.rb +++ b/actionview/lib/action_view/renderer/template_renderer.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require "active_support/core_ext/object/try" - module ActionView class TemplateRenderer < AbstractRenderer #:nodoc: def render(context, options) @@ -54,7 +52,7 @@ module ActionView # supplied as well. def render_template(view, template, layout_name, locals) render_with_layout(view, template, layout_name, locals) do |layout| - instrument(:template, identifier: template.identifier, layout: layout.try(:virtual_path)) do + instrument(:template, identifier: template.identifier, layout: (layout && layout.virtual_path)) do template.render(view, locals) { |*name| view._layout_for(*name) } end end -- cgit v1.2.3