aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view/renderer
diff options
context:
space:
mode:
authorAkira Matsuda <ronnie@dio.jp>2019-08-01 16:41:26 +0900
committerAkira Matsuda <ronnie@dio.jp>2019-08-01 17:58:00 +0900
commitaf2129b4c74732c88ffce76e5c55c805cb9431f6 (patch)
treec74d8c85f81ea6b3a5e4209be247c9d83666bd4d /actionview/lib/action_view/renderer
parentdbf3e4882f9da95e34ed9086f182cf424aaac224 (diff)
downloadrails-af2129b4c74732c88ffce76e5c55c805cb9431f6.tar.gz
rails-af2129b4c74732c88ffce76e5c55c805cb9431f6.tar.bz2
rails-af2129b4c74732c88ffce76e5c55c805cb9431f6.zip
Use `try` only when we're unsure if the receiver would respond_to the method
Diffstat (limited to 'actionview/lib/action_view/renderer')
-rw-r--r--actionview/lib/action_view/renderer/streaming_template_renderer.rb2
-rw-r--r--actionview/lib/action_view/renderer/template_renderer.rb4
2 files changed, 2 insertions, 4 deletions
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