Sha256: d994b4387009bb33e45ba4b2ba98d376a2c4d8b8a71f4fdf032e9d52bab615ed
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 # Cache the given actions. 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
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
nitro-0.41.0 | lib/nitro/caching/actions.rb |
nitro-0.40.0 | lib/nitro/caching/actions.rb |