lib/nitro/caching/actions.rb in nitro-0.27.0 vs lib/nitro/caching/actions.rb in nitro-0.28.0

- old
+ new

@@ -1,52 +1,58 @@ require 'fileutils' +require 'nitro/caching/fragments' + module Nitro # Adds support for caching. module Caching - # Action 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.append_features(base) # :nodoc: - super + def self.included(base) # :nodoc: base.extend(ClassMethods) end module ClassMethods def cache_action(*actions) return unless caching_enabled? - before_filter( + before( %{ fragment_name = "\#\{@action_name\}\#{@request.query_string}" - if fragment = Fragment.get(fragment_name) + if fragment = Fragments.get(fragment_name) @out = fragment return end }, :only => actions ) - after_filter( + after( %{ fragment_name = "\#\{@action_name\}\#{@request.query_string}" - Fragment.put(fragment_name, @out) + Fragments.put(fragment_name, @out) }, :only => actions ) end end private + # Expire the cached fragment of the given actions. + # #-- - # FIXME: not implemented. + # FIXME: not very good implementation? #++ def expire_action(*actions) return unless caching_enabled?