instance method compile!

Ruby on Rails 6.1.7.10

Since v5.2.8.1 Private

Available in: v5.2.8.1 v6.0.6 v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

compile!(view)

Compile a template. This method ensures a template is compiled just once and removes the source after it is compiled.

Parameters

view req
Source
# File actionview/lib/action_view/template.rb, line 238
      def compile!(view)
        return if @compiled

        # Templates can be used concurrently in threaded environments
        # so compilation and any instance variable modification must
        # be synchronized
        @compile_mutex.synchronize do
          # Any thread holding this lock will be compiling the template needed
          # by the threads waiting. So re-check the @compiled flag to avoid
          # re-compilation
          return if @compiled

          mod = view.compiled_method_container

          instrument("!compile_template") do
            compile(mod)
          end

          @compiled = true
        end
      end

Defined in actionview/lib/action_view/template.rb line 238 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActionView::Template

Type at least 2 characters to search.

↑↓ navigate · open · esc close