Module: ActionController::Caching::Sweeping::ClassMethods

Defined in:
lib/action_controller/caching.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#cache_sweeper(*sweepers) ⇒ Object



610
611
612
613
614
615
616
617
618
619
620
621
622
623
# File 'lib/action_controller/caching.rb', line 610

def cache_sweeper(*sweepers)
  return unless perform_caching
  configuration = sweepers.extract_options!
  sweepers.each do |sweeper|
    ActiveRecord::Base.observers << sweeper if defined?(ActiveRecord) and defined?(ActiveRecord::Base)
    sweeper_instance = Object.const_get(Inflector.classify(sweeper)).instance

    if sweeper_instance.is_a?(Sweeper)
      around_filter(sweeper_instance, :only => configuration[:only])
    else
      after_filter(sweeper_instance, :only => configuration[:only])
    end
  end
end