diff options
Diffstat (limited to 'actionview')
-rw-r--r-- | actionview/lib/action_view/template.rb | 9 | ||||
-rw-r--r-- | actionview/test/template/template_test.rb | 7 |
2 files changed, 16 insertions, 0 deletions
diff --git a/actionview/lib/action_view/template.rb b/actionview/lib/action_view/template.rb index 18a5dae270..2dfb14ab46 100644 --- a/actionview/lib/action_view/template.rb +++ b/actionview/lib/action_view/template.rb @@ -235,6 +235,15 @@ module ActionView end end + def marshal_dump + [ @source, @identifier, @handler, @compiled, @original_encoding, @locals, @virtual_path, @updated_at, @formats, @variants ] + end + + def marshal_load(array) + @source, @identifier, @handler, @compiled, @original_encoding, @locals, @virtual_path, @updated_at, @formats, @variants = *array + @compile_mutex = Mutex.new + end + private # Compile a template. This method ensures a template is compiled diff --git a/actionview/test/template/template_test.rb b/actionview/test/template/template_test.rb index 3dc14e36e0..b348d1f17b 100644 --- a/actionview/test/template/template_test.rb +++ b/actionview/test/template/template_test.rb @@ -196,6 +196,13 @@ class TestERBTemplate < ActiveSupport::TestCase assert_match(Regexp.new("\xFC"), e.message) end + def test_template_is_marshalable + template = new_template + serialized = Marshal.load(Marshal.dump(template)) + assert_equal template.identifier, serialized.identifier + assert_equal template.source, serialized.source + end + def with_external_encoding(encoding) old = Encoding.default_external Encoding::Converter.new old, encoding if old != encoding |