From 9a343d148b96874a231b87906c9d6499b5e0b64a Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Mon, 25 Feb 2019 16:33:05 -0800 Subject: [PATCH] Don't mutate `virtual_path`, remove `decorate` `virtual_path` is calculated in the constructor when the Template object is allocated. We don't actually need to set it in the `decorate` method. That means we can remove the decorate method all together. --- actionview/lib/action_view/template.rb | 5 ++--- actionview/lib/action_view/template/resolver.rb | 16 ++-------------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/actionview/lib/action_view/template.rb b/actionview/lib/action_view/template.rb index 1070128d00..09476ceadc 100644 --- a/actionview/lib/action_view/template.rb +++ b/actionview/lib/action_view/template.rb @@ -122,10 +122,8 @@ module ActionView extend Template::Handlers - attr_accessor :virtual_path - attr_reader :source, :identifier, :handler, :original_encoding, :updated_at - attr_reader :variable, :format, :variant, :locals + attr_reader :variable, :format, :variant, :locals, :virtual_path def initialize(source, identifier, handler, format: nil, variant: nil, locals: nil, **details) unless format @@ -158,6 +156,7 @@ module ActionView @compile_mutex = Mutex.new end + deprecate def virtual_path=(_); end deprecate def locals=(_); end deprecate def formats=(_); end deprecate def formats; Array(format); end diff --git a/actionview/lib/action_view/template/resolver.rb b/actionview/lib/action_view/template/resolver.rb index 312299b755..9ca028840f 100644 --- a/actionview/lib/action_view/template/resolver.rb +++ b/actionview/lib/action_view/template/resolver.rb @@ -187,18 +187,10 @@ module ActionView if key @cache.cache(key, name, prefix, partial, locals) do - decorate(yield, path_info, details, locals) + yield end else - decorate(yield, path_info, details, locals) - end - end - - # Ensures all the resolver information is set in the template. - def decorate(templates, path_info, details, locals) - cached = nil - templates.each do |t| - t.virtual_path ||= (cached ||= build_path(*path_info)) + yield end end end @@ -432,9 +424,5 @@ module ActionView def self.instances [new(""), new("/")] end - - def decorate(*) - super.each { |t| t.virtual_path = nil } - end end end