Module: CustomFragmentCache

Extended by:
ActiveSupport::Concern
Includes:
Logic
Defined in:
lib/custom_fragment_cache.rb,
lib/custom_fragment_cache/logic.rb,
lib/custom_fragment_cache/helper.rb,
lib/custom_fragment_cache/railtie.rb,
lib/custom_fragment_cache/version.rb,
lib/custom_fragment_cache/fragment.rb,
lib/custom_fragment_cache/configuration.rb,
lib/custom_fragment_cache/cache_helper_method.rb

Defined Under Namespace

Modules: Helper, Logic Classes: CacheHelperMethod, Configuration, Fragment, Railtie

Constant Summary collapse

VERSION =
"0.0.1"

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Logic

cache_key, #expire_cache?, #expire_fragment, prefix

Class Method Details

.configurationObject



11
12
13
# File 'lib/custom_fragment_cache/configuration.rb', line 11

def self.configuration
  @configuration ||= Configuration.new
end

.configuration=(config) ⇒ Object



15
16
17
# File 'lib/custom_fragment_cache/configuration.rb', line 15

def self.configuration=(config)
  @configuration = config
end

.configure {|configuration| ... } ⇒ Object

Yields:



19
20
21
# File 'lib/custom_fragment_cache/configuration.rb', line 19

def self.configure
  yield(configuration) if block_given?
end

Instance Method Details

#after_save(record) ⇒ Object

Observer support



21
22
23
# File 'lib/custom_fragment_cache.rb', line 21

def after_save(record)
  fragments_validity(record)
end

#fragments_validity(record = self) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/custom_fragment_cache.rb', line 25

def fragments_validity(record = self)
  self.class.fragment_caches.each do |fragment_cache|
    if expire_cache?(fragment_cache, record)
      expire_fragment(cache_key(fragment_cache.name, record))
    end
  end
end