mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
da8cb4fa3d
Templates only have one variant, so we should not store it in an array. This commit converts `variants` to `variant` and deprecates the plural accessor
33 lines
988 B
Ruby
33 lines
988 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "action_view/template"
|
|
|
|
module ActionView
|
|
class FileTemplate < Template
|
|
def initialize(filename, handler, details)
|
|
@filename = filename
|
|
|
|
super(nil, filename, handler, details)
|
|
end
|
|
|
|
def source
|
|
File.binread @filename
|
|
end
|
|
|
|
def refresh(_)
|
|
self
|
|
end
|
|
|
|
# Exceptions are marshalled when using the parallel test runner with DRb, so we need
|
|
# to ensure that references to the template object can be marshalled as well. This means forgoing
|
|
# the marshalling of the compiler mutex and instantiating that again on unmarshalling.
|
|
def marshal_dump # :nodoc:
|
|
[ @identifier, @handler, @compiled, @original_encoding, @locals, @virtual_path, @updated_at, @format, @variant ]
|
|
end
|
|
|
|
def marshal_load(array) # :nodoc:
|
|
@identifier, @handler, @compiled, @original_encoding, @locals, @virtual_path, @updated_at, @format, @variant = *array
|
|
@compile_mutex = Mutex.new
|
|
end
|
|
end
|
|
end
|