aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view/template/inline.rb
blob: 44658487ea7682bc95729779d785ae80fcfe33fb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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