diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2013-01-08 10:29:50 -0800 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2013-01-08 10:29:50 -0800 |
commit | 64e3660ff0c0fd708fd4fc5455c54bf3d511032b (patch) | |
tree | 59ea8b888d7bc9c99cdcfab3ad4bf0f346244054 /actionpack/lib/action_controller | |
parent | ac86cbec82acee18a5066e00b98d1c20fc677a15 (diff) | |
parent | 70e684a681352e95fb990747ef6dd7183da333a8 (diff) | |
download | rails-64e3660ff0c0fd708fd4fc5455c54bf3d511032b.tar.gz rails-64e3660ff0c0fd708fd4fc5455c54bf3d511032b.tar.bz2 rails-64e3660ff0c0fd708fd4fc5455c54bf3d511032b.zip |
Merge pull request #8818 from jamis/master
view_cache_dependency API
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r-- | actionpack/lib/action_controller/caching.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/caching.rb b/actionpack/lib/action_controller/caching.rb index 2892e093af..e31743bcc7 100644 --- a/actionpack/lib/action_controller/caching.rb +++ b/actionpack/lib/action_controller/caching.rb @@ -70,12 +70,30 @@ module ActionController config_accessor :perform_caching self.perform_caching = true if perform_caching.nil? + + class_attribute :_view_cache_dependencies + self._view_cache_dependencies = [] + helper_method :view_cache_dependencies if respond_to?(:helper_method) + end + + module ClassMethods + def view_cache_dependency(&dependency) + self._view_cache_dependencies += [dependency] + end + + def view_cache_dependencies + _view_cache_dependencies.map { |dep| instance_exec &dep }.compact + end end def caching_allowed? request.get? && response.status == 200 end + def view_cache_dependencies + self.class.view_cache_dependencies + end + protected # Convenience accessor. def cache(key, options = {}, &block) |