Sha256: 446a1c321adf2e24247e3c8bc7f5844e9af5e7f05040917d8cfa0ff8fe18b216

Contents?: true

Size: 867 Bytes

Versions: 3

Compression:

Stored size: 867 Bytes

Contents

module Immunio
  module CacheStoreHooks
    extend ActiveSupport::Concern

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

    # Rails 5 adds CollectionCaching. When used in the context of
    # rendering a collection of items with a partial template, we
    # need to remove our markers before writing to the cache store.
    # See this blog post for more:
    # http://blog.bigbinary.com/2016/03/09/rails-5-makes-partial-redering-from-cache-substantially-faster.html
    def write_with_immunio(name, value, options = nil)
      Request.time "plugin", "#{Module.nesting[0]}::#{__method__}" do
        Template.remove_all_markers! value if value.is_a? String

        Request.pause "plugin", "#{Module.nesting[0]}::#{__method__}" do
          write_without_immunio(name, value, options)
        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/cache_store.rb
immunio-2.0.3 lib/immunio/plugins/action_view/cache_store.rb
immunio-2.0.2 lib/immunio/plugins/action_view/cache_store.rb