public
Fork of NZKoz/koz-rails
Description: Koz's rails git-svn clone
Homepage: http://www.rubyonrails.org
Clone URL: git://github.com/eventualbuddha/koz-rails.git
Added support for naming concrete classes in sweeper declarations [DHH]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8819 
5ecf4fe2-1ee6-0310-87b1-e25e094e27de
david (author)
Thu Feb 07 14:50:49 -0800 2008
commit  215f5d04c95450146384c2f5d7fce054fe8bb18c
tree    c7c567498da7ac994003082b00ad9a7d414524bb
parent  7bc7bf55d508b6dde2e8580f48c4f28737ad9221
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 *SVN*
0
 
0
+* Added support for naming concrete classes in sweeper declarations [DHH]
0
+
0
 * Remove ERB trim variables from trace template in case ActionView::Base.erb_trim_mode is changed in the application. #10098 [tpope, kampers]
0
 
0
 * Fix typo in form_helper documentation. #10650 [xaviershay, kampers]
...
22
23
24
 
 
 
 
 
 
 
25
26
27
...
31
32
33
 
34
35
36
 
37
38
39
...
22
23
24
25
26
27
28
29
30
31
32
33
34
...
38
39
40
41
42
43
 
44
45
46
47
0
@@ -22,6 +22,13 @@ module ActionController #:nodoc:
0
     # end
0
     #
0
     # In the example above, four actions are cached and three actions are responsible for expiring those caches.
0
+ #
0
+ # You can also name an explicit class in the declaration of a sweeper, which is needed if the sweeper is in a module:
0
+ #
0
+ # class ListsController < ApplicationController
0
+ # caches_action :index, :show, :public, :feed
0
+ # cache_sweeper OpenBar::Sweeper, :only => [ :edit, :destroy, :share ]
0
+ # end
0
     module Sweeping
0
       def self.included(base) #:nodoc:
0
         base.extend(ClassMethods)
0
@@ -31,9 +38,10 @@ module ActionController #:nodoc:
0
         def cache_sweeper(*sweepers)
0
           return unless perform_caching
0
           configuration = sweepers.extract_options!
0
+
0
           sweepers.each do |sweeper|
0
             ActiveRecord::Base.observers << sweeper if defined?(ActiveRecord) and defined?(ActiveRecord::Base)
0
- sweeper_instance = Object.const_get(Inflector.classify(sweeper)).instance
0
+ sweeper_instance = (sweeper.is_a?(Symbol) ? Object.const_get(Inflector.classify(sweeper)) : sweeper).instance
0
 
0
             if sweeper_instance.is_a?(Sweeper)
0
               around_filter(sweeper_instance, :only => configuration[:only])

Comments

    No one has commented yet.