diff options
author | Aaron Patterson <tenderlove@github.com> | 2019-02-22 23:00:30 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-22 23:00:30 -0800 |
commit | be442ccd8342baf39e73b01a6fdd38e1a3b15c2c (patch) | |
tree | 493c96e9836fa06ea7fa1eae5b358088e05c02c6 /actionview/lib/action_view/template | |
parent | f3641b187e93808ceadd1e0d4b45ad7a484be4d9 (diff) | |
parent | 52eafbd7495367aa48192100a922181d097e5b22 (diff) | |
download | rails-be442ccd8342baf39e73b01a6fdd38e1a3b15c2c.tar.gz rails-be442ccd8342baf39e73b01a6fdd38e1a3b15c2c.tar.bz2 rails-be442ccd8342baf39e73b01a6fdd38e1a3b15c2c.zip |
Merge pull request #35374 from rails/cache-inline-templates
Add a finalizer to inline templates
Diffstat (limited to 'actionview/lib/action_view/template')
-rw-r--r-- | actionview/lib/action_view/template/inline.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/actionview/lib/action_view/template/inline.rb b/actionview/lib/action_view/template/inline.rb new file mode 100644 index 0000000000..44658487ea --- /dev/null +++ b/actionview/lib/action_view/template/inline.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module ActionView #:nodoc: + class Template #:nodoc: + class Inline < Template #:nodoc: + # This finalizer is needed (and exactly with a proc inside another proc) + # otherwise templates leak in development. + Finalizer = proc do |method_name, mod| # :nodoc: + proc do + mod.module_eval do + remove_possible_method method_name + end + end + end + + def compile(mod) + super + ObjectSpace.define_finalizer(self, Finalizer[method_name, mod]) + end + end + end +end |