Sha256: 2e71f89e61a75e56c18c117e235299f8bed137c3a12d3507deb27331a8ac26f4

Contents?: true

Size: 1.24 KB

Versions: 3

Compression:

Stored size: 1.24 KB

Contents

module Immunio
  # Hook for the `ActionView::TemplateRenderer`. These are called for root
  # templates.
  module TemplateRendererHooks
    extend ActiveSupport::Concern

    included do
      Immunio::Utils.alias_method_chain self, :render_template, :immunio
    end

    def render_template_with_immunio(template, *args)
      Request.time "plugin", "#{Module.nesting[0]}::#{__method__}" do
        renderer = Template.new(template)

        renderer.render @view do
          Request.pause "plugin", "#{Module.nesting[0]}::#{__method__}" do
            render_template_without_immunio(template, *args)
          end
        end
      end
    end
  end

  # Hook for the `ActionView::Template`. These are called for non-root
  # templates.
  module TemplateHooks
    extend ActiveSupport::Concern

    included do
      Immunio::Utils.alias_method_chain self, :render, :immunio
    end

    def render_with_immunio(context, *args, &block)
      Request.time "plugin", "#{Module.nesting[0]}::#{__method__}" do
        renderer = Template.new(self)

        renderer.render context do
          Request.pause "plugin", "#{Module.nesting[0]}::#{__method__}" do
            render_without_immunio(context, *args, &block)
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
immunio-2.0.4 lib/immunio/plugins/action_view/template_rendering.rb
immunio-2.0.3 lib/immunio/plugins/action_view/template_rendering.rb
immunio-2.0.2 lib/immunio/plugins/action_view/template_rendering.rb