Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 8819

Show
Ignore:
Timestamp:
02/07/08 22:50:49 (7 months ago)
Author:
david
Message:

Added support for naming concrete classes in sweeper declarations [DHH]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/CHANGELOG

    r8813 r8819  
    11*SVN* 
     2 
     3* Added support for naming concrete classes in sweeper declarations [DHH] 
    24 
    35* Remove ERB trim variables from trace template in case ActionView::Base.erb_trim_mode is changed in the application.  #10098 [tpope, kampers] 
  • trunk/actionpack/lib/action_controller/caching/sweeping.rb

    r8546 r8819  
    2323    # 
    2424    # In the example above, four actions are cached and three actions are responsible for expiring those caches. 
     25    # 
     26    # You can also name an explicit class in the declaration of a sweeper, which is needed if the sweeper is in a module: 
     27    # 
     28    #   class ListsController < ApplicationController 
     29    #     caches_action :index, :show, :public, :feed 
     30    #     cache_sweeper OpenBar::Sweeper, :only => [ :edit, :destroy, :share ] 
     31    #   end     
    2532    module Sweeping 
    2633      def self.included(base) #:nodoc: 
     
    3239          return unless perform_caching 
    3340          configuration = sweepers.extract_options! 
     41 
    3442          sweepers.each do |sweeper| 
    3543            ActiveRecord::Base.observers << sweeper if defined?(ActiveRecord) and defined?(ActiveRecord::Base) 
    36             sweeper_instance = Object.const_get(Inflector.classify(sweeper)).instance 
     44            sweeper_instance = (sweeper.is_a?(Symbol) ? Object.const_get(Inflector.classify(sweeper)) : sweeper).instance 
    3745 
    3846            if sweeper_instance.is_a?(Sweeper)