Class: Skylight::Core::Probes::ActionView::Probe Private

Inherits:
Object
  • Object
show all
Defined in:
lib/skylight/core/probes/action_view.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#installObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/skylight/core/probes/action_view.rb', line 5

def install
  ::ActionView::TemplateRenderer.class_eval do
    alias_method :render_with_layout_without_sk, :render_with_layout

    def render_with_layout(*args, &block) #:nodoc:
      path, locals = case args.length
                     when 2
                       args
                     when 4
                       # Rails > 6.0.0.beta3 arguments are (view, template, path, locals)
                       [args[2], args[3]]
                     end

      layout = nil

      if path
        layout =
          if ::ActionView::VERSION::MAJOR >= 5
            find_layout(path, locals.keys, [formats.first])
          else
            find_layout(path, locals.keys)
          end
      end

      if layout
        instrument(:template, identifier: layout.identifier) do
          render_with_layout_without_sk(*args, &block)
        end
      else
        render_with_layout_without_sk(*args, &block)
      end
    end
  end
end