Sha256: f2d13a55dc999d244c7aa4143bb4b65f637da120773575ddf976547e3d1eaa73
Contents?: true
Size: 1.37 KB
Versions: 2
Compression:
Stored size: 1.37 KB
Contents
require 'fileutils' require 'nitro/caching/fragments' module Nitro # Adds support for caching. module Caching # Action caching is a set of helper to allow the caching # generated by an action. In the caching hierarchy it lies # between Output caching (top action, full page) and fragment # caching (fine-grained caching). module Actions def self.included(base) # :nodoc: base.extend(ClassMethods) end module ClassMethods def cache_action(*actions) return unless caching_enabled? before( %{ fragment_name = "\#\{@action_name\}\#{@request.query_string}" if fragment = Fragments.get(fragment_name) @out = fragment return end }, :only => actions ) after( %{ fragment_name = "\#\{@action_name\}\#{@request.query_string}" Fragments.put(fragment_name, @out) }, :only => actions ) end end private # Expire the cached fragment of the given actions. # #-- # FIXME: not very good implementation? #++ def expire_action(*actions) return unless caching_enabled? for action in [actions].flatten expire_fragment(action) end end end end end # * George Moschovitis <gm@navel.gr>
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
nitro-0.28.0 | lib/nitro/caching/actions.rb |
nitro-0.29.0 | lib/nitro/caching/actions.rb |