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


499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
# File 'lib/action_controller/caching.rb', line 499

def cache_sweeper(*sweepers)
  return unless perform_caching
  configuration = sweepers.last.is_a?(Hash) ? sweepers.pop : {}
  sweepers.each do |sweeper|
    observer(sweeper)

    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