Module: SplitTester::Caching
- Defined in:
- lib/split_tester/caching.rb
Overview
:nodoc:
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
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 |
# File 'lib/split_tester/caching.rb', line 5 def self.included(base) base.class_eval { def fragment_cache_key(key, namespace = nil) namespace ||= is_split_test? ? "views-split-#{current_split_test_key}" : :views ActiveSupport::Cache.(key.is_a?(Hash) ? url_for(key).split("://").last : key, namespace) end def expire_fragment(key, = nil) return unless cache_configured? key = fragment_cache_key(key, :views) unless key.is_a?(Regexp) = nil instrument_fragment_cache :expire_fragment, key do if key.is_a?(Regexp) cache_store.delete_matched(key, ) else cache_store.delete(key, ) end end unless key.is_a?(Regexp) original_key = key.dup SplitTester::Base.test_keys.each do |k,v| key = original_key.sub('views/', "views-split-#{k}/") instrument_fragment_cache :expire_fragment, key do cache_store.delete(key, ) end end end end } end |