Sha256: ce4423657a53814c66ac5306cb36a05b3b5b8f396f63ca9510952753c6ef0602

Contents?: true

Size: 1.58 KB

Versions: 32

Compression:

Stored size: 1.58 KB

Contents

module Skylight
  module Probes
    module ActionView
      class Probe
        def install
          # Rails 3.0 didn't have ActionView::TemplateRenderer, but it also
          # didn't have the bug that this probe is trying to fix. In Rails
          # 3.1, a templating engine refactor moved the layout rendering out
          # of the existing instrumentation, making any other events that
          # happen inside of the layout appear to happen directly inside the
          # parent (usually the controller).
          return if [ActionPack::VERSION::MAJOR, ActionPack::VERSION::MINOR] == [3, 0]

          ::ActionView::TemplateRenderer.class_eval do
            alias render_with_layout_without_sk render_with_layout

            def render_with_layout(path, locals, *args, &block) #:nodoc:
              layout = nil

              if path
                if method(:find_layout).arity == 3
                  # Rails 5
                  layout = find_layout(path, locals.keys, [formats.first])
                else
                  # Rails 3, 4
                  layout = find_layout(path, locals.keys)
                end
              end

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

    register("ActionView::TemplateRenderer", "action_view", ActionView::Probe.new)
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
skylight-1.5.1 lib/skylight/probes/action_view.rb
skylight-1.5.0 lib/skylight/probes/action_view.rb
skylight-1.4.4 lib/skylight/probes/action_view.rb
skylight-1.4.3 lib/skylight/probes/action_view.rb
skylight-1.4.2 lib/skylight/probes/action_view.rb
skylight-1.4.1 lib/skylight/probes/action_view.rb
skylight-1.4.0 lib/skylight/probes/action_view.rb
skylight-1.4.0.beta.2 lib/skylight/probes/action_view.rb
skylight-1.4.0.beta lib/skylight/probes/action_view.rb
skylight-1.3.1 lib/skylight/probes/action_view.rb
skylight-1.3.0 lib/skylight/probes/action_view.rb
skylight-1.2.2 lib/skylight/probes/action_view.rb
skylight-1.2.1 lib/skylight/probes/action_view.rb
skylight-1.2.0 lib/skylight/probes/action_view.rb
skylight-1.1.0 lib/skylight/probes/action_view.rb
skylight-1.0.1 lib/skylight/probes/action_view.rb
skylight-1.0.0 lib/skylight/probes/action_view.rb
skylight-0.10.6 lib/skylight/probes/action_view.rb
skylight-1.0.0.beta5 lib/skylight/probes/action_view.rb
skylight-0.10.5 lib/skylight/probes/action_view.rb