Module: Cashier::ControllerHelper

Defined in:
lib/controller_helper.rb

Class Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/controller_helper.rb', line 16

def self.included(klass)
  klass.class_eval do
    def write_fragment_with_tagged_key(key, content, options = nil)
      if options && options[:tag] && Cashier.perform_caching? 
        tags = case options[:tag].class.to_s
               when 'Proc', 'Lambda'
                 options[:tag].call(self)
               else 
                 options[:tag]
               end
        Cashier.store_fragment fragment_cache_key(key), *tags
      end
      write_fragment_without_tagged_key(key, content, options)
    end
    alias_method_chain :write_fragment, :tagged_key
  end
end