# * George Moschovitis # (c) 2004-2005 Navel, all rights reserved. # $Id: actions.rb 326 2005-03-28 11:07:17Z gmosx $ require 'fileutils' module N # Adds support for caching. module Caching # Action caching. module Actions def self.append_features(base) # :nodoc: super base.extend(ClassMethods) end module ClassMethods def cache_action(*actions) return unless caching_enabled before_filter( %{ fragment_name = "\#\{@action_name\}\#{@request.query_string}" if fragment = Fragment.get(fragment_name) @out = fragment return end }, :only => actions ) after_filter( %{ fragment_name = "\#\{@action_name\}\#{@request.query_string}" Fragment.put(fragment_name, @out) }, :only => actions ) end end private #-- # FIXME: not implemented. #++ def expire_action(*actions) return unless caching_enabled for action in [actions].flatten expire_fragment(action) end end end end end