mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
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.
This commit is contained in:
parent
d4015a7f06
commit
9a343d148b
2 changed files with 4 additions and 17 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue